QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#514086 | #9170. Cycle Game | ucup-team4504# | WA | 0ms | 3724kb | C++17 | 1.4kb | 2024-08-10 21:41:46 | 2024-08-10 21:41:46 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 1e6 + 5;
int n, m, q;
bool vis[N];
int V, E, F, C;
int fa[N]; int getfa(int x){return x == fa[x] ? x : fa[x] = getfa(fa[x]);}
int getid(int x, int y){
return x * (m + 2) + y;
}
void calc(){
V = E = F = C = 0;
for (int i = 0; i < (n + 2) * (m + 2); i++) fa[i] = i;
for (int i = 0; i <= n + 1; i++)
for (int j = 0; j <= m + 1; j++){
if (i && !vis[getid(i, j)] && !vis[getid(i - 1, j)]) E++, fa[getfa(getid(i, j))] = getfa(getid(i - 1, j));
if (j && !vis[getid(i, j)] && !vis[getid(i, j - 1)]) E++, fa[getfa(getid(i, j))] = getfa(getid(i, j - 1));
if (i && j && !vis[getid(i, j)] && !vis[getid(i - 1, j - 1)]) E++, fa[getfa(getid(i, j))] = getfa(getid(i - 1, j - 1));
if (i && j && !vis[getid(i, j - 1)] && !vis[getid(i - 1, j)]) E++, fa[getfa(getid(i, j - 1))] = getfa(getid(i - 1, j));
}
for (int i = 0; i <= n + 1; i++)
for (int j = 0; j <= m + 1; j++)
if (!vis[getid(i, j)] && getid(i, j) == fa[getid(i, j)])
C++;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("in.txt", "r", stdin);
// freopen("out2.txt", "w", stdout);
cin >> n >> m >> q;
while (q--){
int x, y;
cin >> x >> y;
if (vis[getid(x, y)]){
putchar('1');
continue;
}
vis[getid(x, y)] = 1;
calc();
if (C > 1){
putchar('0');
vis[getid(x, y)] = 0;
}else putchar('1');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
4 3 7 2 1 2 2 2 3 3 1 3 2 4 1 4 2
output:
1111111
result:
ok "1111111"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
3 3 8 1 1 1 2 1 3 2 3 3 3 3 2 3 1 2 1
output:
11111110
result:
ok "11111110"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
10 10 7 9 1 6 6 3 8 8 7 5 10 1 7 1 2
output:
1111111
result:
ok "1111111"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
9 10 50 1 9 1 6 2 3 3 1 7 4 9 4 1 3 2 5 9 2 7 9 5 6 8 10 9 5 5 5 4 10 9 7 5 9 3 2 4 5 1 1 4 7 3 6 2 8 4 3 8 6 5 10 4 8 5 4 7 2 9 6 4 2 7 8 5 2 3 5 9 1 6 1 1 5 9 9 5 8 6 3 8 8 8 4 7 7 7 1 3 7 2 2 3 10 6 9 8 3 7 6
output:
11111111111111111111111111111111111111111111111111
result:
ok "11111111111111111111111111111111111111111111111111"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
3 5 11 1 5 2 4 1 2 1 3 3 3 3 1 3 4 2 3 1 4 2 1 2 5
output:
11111111111
result:
ok "11111111111"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
7 9 12 7 3 2 3 6 2 2 2 4 2 2 8 5 7 4 4 6 8 2 7 7 2 1 9
output:
111111111111
result:
ok "111111111111"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
1 4 1 1 2
output:
1
result:
ok "1"
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3720kb
input:
9 8 67 5 5 8 3 9 5 7 4 5 1 9 3 4 2 2 5 1 7 7 8 7 2 8 5 6 1 8 8 4 4 5 4 1 5 3 4 6 7 2 3 3 7 5 7 2 4 2 7 1 3 7 3 2 8 6 6 6 2 6 3 7 5 9 6 7 6 3 6 1 1 6 4 3 1 5 3 8 7 2 1 4 1 8 4 8 6 3 5 5 8 1 6 1 2 4 6 9 4 1 4 3 3 4 8 8 1 4 7 9 8 3 8 6 5 6 8 3 2 2 2 7 1 9 2 4 3 1 8 4 5 8 2 7 7
output:
1111111111111111111111111111111111111111111110011111101010001101111
result:
wrong answer 1st words differ - expected: '111111111111111111111111111111...1111111110010101101000101101101', found: '111111111111111111111111111111...1111111110011111101010001101111'