Coinisi.

1.2万

kzyz
こんにちは
2208114119
dushucheng0901
zzlhh
Plankton
Lloyd_Gabriel_Lmd

Poke_02
Q星星

Chenr

jacksonhack
@陈先生

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <unordered_map>
#include <unordered_set>

//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#define IOS std::ios::sync_with_stdio(false)
#define pb push_back
#define inf 0x3f3f3f3f
#define YES cout << "YES" << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define NO cout << "NO" << endl;
#define int long long
#define x first
#define y second
#define cmp [&](PII a, PII b){ return a.y < b.y; }

const int N = 5e5+10, mod = 1e9+7, M = 1e6+5, K = 1e5+10, Z = 2e5+7;

using namespace std;
typedef long long LL;
typedef priority_queue<int> PQI;
typedef priority_queue <int, vector<int>, greater<>> PQGI;
typedef pair<int, int> PII;

bool st[55][55];
char g[55][55];
int n, m;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
vector<PII> a, b;

int get(int x1, int y1, int x2, int y2)
{
return abs(x1 - x2) + abs(y1 - y2);
}

void bfs(int x, int y, int k)
{
queue<PII> q;
if(!k) a.pb({x, y});
else b.pb({x, y});

q.push({x, y});
st[x][y] = true;

while(q.size())
{
PII t = q.front();
q.pop();
int sx = t.first, sy = t.second;
for(int i = 0; i < 4; i ++)
{
int nx = sx + dx[i], ny = sy + dy[i];
if(nx >= 0 && nx <= n && ny >= 0 && ny <= m && g[nx][ny] == 'X' && !st[nx][ny])
{
q.push({nx, ny});
if(!k) a.pb({nx, ny});
else b.pb({nx, ny});
st[nx][ny] = true;
}
}
}
}

void solve()
{
cin >> n >> m;
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= m; j ++)
cin >> g[i][j];

int t = 0;
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= m; j ++)
if(g[i][j] == 'X' && !st[i][j])
{
bfs(i, j, t);
t = 1;
}

int res = inf;

for(int i = 0; i < a.size(); i ++)
for(int j = 0; j < b.size(); j ++)
res = min(res, get(a[i].first, a[i].second, b[j].first, b[j].second));

cout << res - 1 << endl;
return;
}

signed main()
{
IOS; cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
// cin >> T;
while( T -- ) solve();
return 0;
}
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


Coinisi.
10天前
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <unordered_map>
#include <unordered_set>

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#define IOS std::ios::sync_with_stdio(false)
#define pb push_back
#define inf 0x3f3f3f3f
#define YES cout << "YES" << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define NO cout << "NO" << endl;
#define int long long
#define x first
#define y second
#define cmp [&](PII a, PII b){ return a.y < b.y; }

const int N = 5e5+10, mod = 1e9+7, M = 1e6+5, K = 1e5+10, Z = 2e5+7;

using namespace std;
typedef long long LL;
typedef priority_queue<int> PQI;
typedef priority_queue <int, vector<int>, greater<>> PQGI;
typedef pair<int, int> PII;

int t, st[5010], tt;

int get_sum(int n)
{
int sum = 0;
for(int i = 1; i <= n; i ++)
sum += i;
return sum;
}

void solve()
{
t ++, tt = 0;
memset(st, 0, sizeof st);
int n, x, y; cin >> n >> x >> y;

int sum = get_sum(n), s = x + y;

if(sum % s == 0)
{
cout << "Case #" << t << ':' << " POSSIBLE" << endl;
int h1 = sum / s * y, h2 = sum - h1;

if(h2 <= n) {cout << 1 << endl << h2 << endl; return;}
else
{
for(int i = n; i >= 1; i --)
{
if(i > h2) continue;
h2 = h2 - i, st[++ tt] = i;
if(h2 <= i - 1) {st[++ tt] = h2; break;}
else continue;
}
}

cout << tt << endl;
for(int i = 1; i <= tt; i ++) cout << st[i] << ' ';
cout << endl;
}
else if(sum % s != 0)
cout << "Case #" << t << ':' << " IMPOSSIBLE" << endl;

return;
}

signed main()
{
IOS; cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
cin >> T;
while( T -- ) solve();
return 0;
}


Coinisi.
10天前
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <unordered_map>
#include <unordered_set>

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#define IOS std::ios::sync_with_stdio(false)
#define pb push_back
#define inf 0x3f3f3f3f
#define YES cout << "YES" << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define NO cout << "NO" << endl;
#define int long long
#define x first
#define y second
#define cmp [&](PII a, PII b){ return a.y < b.y; }

const int N = 5e5+10, mod = 1e9+7, M = 1e6+5, K = 1e5+10, Z = 2e5+7;

using namespace std;
typedef long long LL;
typedef priority_queue<int> PQI;
typedef priority_queue <int, vector<int>, greater<>> PQGI;
typedef pair<int, int> PII;

char str[1010], ch[27];

int get_idx(char c)
{
for(int i = 1; i <= 26; i ++)
if(ch[i] == c) return i;
return 0;
}

void solve()
{
cin >> (ch + 1) >> (str + 1);

int cnt = 1, t = strlen(str + 1);

for(int i = 2; i <= t; i ++)
{
int s1 = get_idx(str[i]), s2 = get_idx(str[i - 1]);
if(s1 <= s2) cnt ++;
}

cout << cnt << endl;
}

signed main()
{
IOS; cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
//    cin >> T;
while( T -- ) solve();
return 0;
}


Coinisi.
10天前
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <unordered_map>
#include <unordered_set>

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#define IOS std::ios::sync_with_stdio(false)
#define pb push_back
#define inf 0x3f3f3f3f
#define YES cout << "YES" << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define NO cout << "NO" << endl;
#define int long long
#define x first
#define y second
#define cmp [&](PII a, PII b){ return a.y < b.y; }

const int N = 5e5+10, mod = 1e9+7, M = 1e6+5, K = 1e5+10, Z = 2e5+7;

using namespace std;
typedef long long LL;
typedef priority_queue<int> PQI;
typedef priority_queue <int, vector<int>, greater<>> PQGI;
typedef pair<int, int> PII;

char str[1010], ch[27];

int get_idx(char c)
{
for(int i = 1; i <= 26; i ++)
if(ch[i] == c) return i;
return 0;
}

void solve()
{
cin >> (ch + 1) >> (str + 1);

int cnt = 1, t = strlen(str + 1);

for(int i = 2; i <= t; i ++)
{
int s1 = get_idx(str[i]), s2 = get_idx(str[i - 1]);
if(s1 <= s2) cnt ++;
}

cout << cnt << endl;
}

signed main()
{
IOS; cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
//    cin >> T;
while( T -- ) solve();
return 0;
}
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


Coinisi.
14天前
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <unordered_map>
#include <unordered_set>

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#define IOS std::ios::sync_with_stdio(false)
#define inf 0x3f3f3f3f
#define pb push_back
#define YES cout << "YES" << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define NO cout << "NO" << endl;
#define int long long
#define x first
#define y second
#define cmp [&](PII a, PII b){ return a.y < b.y; }

const int N = 5e5+10, mod = 1e9+7, M = 1e6+5, K = 1e5+10, Z = 2e5+7;

using namespace std;
typedef long long LL;
typedef priority_queue<int> PQI;
typedef priority_queue <int, vector<int>, greater<>> PQGI;
typedef pair<int, int> PII;

int cnt;
char ch[Z];
vector<int> s;

void solve()
{
int n, a, b, k; cin >> n >> a >> b >> k >> (ch + 1);
for(int i = 1; i <= n; i ++)
{
if(ch[i] == '0')
{
cnt ++;
if(cnt == b)
{
s.pb(i);
cnt = 0;
}
}
else cnt = 0;
}

cout << s.size() - a + 1 << endl;
for (int i = 0; i < s.size() - a + 1; i ++) cout << s[i] << " ";
}

signed main()
{
IOS; cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
// cin >> T;
while( T -- ) solve();
return 0;
}


Coinisi.
14天前
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <unordered_map>
#include <unordered_set>

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#define IOS std::ios::sync_with_stdio(false)
#define inf 0x3f3f3f3f
#define YES cout << "YES" << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define NO cout << "NO" << endl;
#define int long long
#define x first
#define y second
#define cmp [&](PII a, PII b){ return a.y < b.y; }

const int N = 5e5+10, mod = 1e9+7, M = 1e6+5, K = 1e5+10, Z = 2e5+7;

using namespace std;
typedef long long LL;
typedef priority_queue<int> PQI;
typedef priority_queue <int, vector<int>, greater<>> PQGI;
typedef pair<int, int> PII;

void solve()
{
int x, y, a, b; cin >> x >> y >> a >> b;
int v = a + b, s = y - x;

if(s % v == 0) cout << s / v << endl;
else cout << -1 << endl;
return;
}

signed main()
{
IOS; cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
cin >> T;
while( T -- ) solve();
return 0;
}


Coinisi.
14天前
//这里填你的代码^^
#include <iostream>

#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

const int N = 2e5+10;

int a[N];

using namespace std;

int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);

int n; cin >> n;
for(int i = 1; i <= n; i ++) cin >> a[i];
a[1] = a[1] % 2;

for(int i = 2; i <= n; i ++)
{
if(a[i] < a[i - 1]) {NO; return 0;}

a[i] = a[i] - a[i - 1], a[i] = a[i] % 2;
}
if(a[n]) NO;
else YES;
return 0;
}
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


Coinisi.
14天前
#include <iostream>

#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

const int N = 2e5+10;

int a[N];

using namespace std;

int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);

int n; cin >> n;
for(int i = 1; i <= n; i ++) cin >> a[i];
a[1] = a[1] % 2;

for(int i = 2; i <= n; i ++)
{
if(a[i] < a[i - 1]) {NO; return 0;}

a[i] = a[i] - a[i - 1], a[i] = a[i] % 2;
}
if(a[n]) NO;
else YES;
return 0;
}


Coinisi.
15天前
#include <iostream>
#include <cmath>

#define empty cout << "EMPTY"

int a[10000000];

using namespace std;

int jym(int n)
{
int sum = 0;
for(int i = 0; i < (n - 1); i ++)
sum = sum + pow(2, i);
return sum;
}

int main()
{
int n; cin >> n;

for(int i = 1; i <= n; i ++) cin >> a[i];

int rol; cin >> rol;

if(rol == 0) empty;
else
{
for(int i = pow(2, rol - 1); i <= pow(2, rol) - 1; i ++)
if(a[i] != 0) cout << a[i] << ' ';
else if(a[i] == 0 && i == pow(2, rol - 1)) empty;

puts("");
}
return 0;
}


Coinisi.
15天前
//这里填你的代码^^
#include <iostream>
#include <cstring>
#include <algorithm>

typedef long long LL;

using namespace std;

int main()
{
int k; cin >> k;
while( k -- )
{
LL n, e, d; cin >> n >> e >> d;// n 为 p * q;
LL ed = e * d, s = n + 2 - ed;// s 为 p + q;
// LL m = n - ed + 2; m 为 s;

LL l = 1, r = s >> 1;
while(l < r)
{
LL mid = (l + r) >> 1;
if(mid * (s - mid) >= n) r = mid;
else l = mid + 1;
}
if(l * (s - l) == n) cout << l << ' ' << s - l << endl;
else puts("NO");
}
return 0;
}
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~