# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
427897 | 2021-06-15T04:27:36 Z | 반딧불(#7617) | Counterspells (CPSPC17_counterspells) | C++17 | 1000 ms | 2432 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; int par[200002]; int cnt[200002]; /// �ڽ� ���� �߿��� �������� ���� �� bool col[200002]; int ans; int main(){ scanf("%d", &n); par[0] = -1; for(int i=1; i<=n; i++){ int x; scanf("%d", &x); col[i] = 1; par[i] = x; ans = 0; int c = 1; while(x>=0){ cnt[x] += c; if(cnt[x]==1 && c==1){ col[x] = 0; c = -1; ans++; } else if(!cnt[x] && c==-1){ col[x] = 1; c = 1; ans++; } else c = 0; x = par[x]; } printf("%d\n", ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 2 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 2 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 4 ms | 332 KB | Output is correct |
9 | Correct | 147 ms | 356 KB | Output is correct |
10 | Correct | 3 ms | 332 KB | Output is correct |
11 | Correct | 3 ms | 332 KB | Output is correct |
12 | Correct | 4 ms | 372 KB | Output is correct |
13 | Correct | 9 ms | 332 KB | Output is correct |
14 | Correct | 24 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 2 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 4 ms | 332 KB | Output is correct |
9 | Correct | 147 ms | 356 KB | Output is correct |
10 | Correct | 3 ms | 332 KB | Output is correct |
11 | Correct | 3 ms | 332 KB | Output is correct |
12 | Correct | 4 ms | 372 KB | Output is correct |
13 | Correct | 9 ms | 332 KB | Output is correct |
14 | Correct | 24 ms | 376 KB | Output is correct |
15 | Correct | 32 ms | 1268 KB | Output is correct |
16 | Execution timed out | 1085 ms | 660 KB | Time limit exceeded |
17 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 74 ms | 2428 KB | Output is correct |
2 | Correct | 66 ms | 2016 KB | Output is correct |
3 | Correct | 32 ms | 1348 KB | Output is correct |
4 | Correct | 48 ms | 2432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 2 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 4 ms | 332 KB | Output is correct |
9 | Correct | 147 ms | 356 KB | Output is correct |
10 | Correct | 3 ms | 332 KB | Output is correct |
11 | Correct | 3 ms | 332 KB | Output is correct |
12 | Correct | 4 ms | 372 KB | Output is correct |
13 | Correct | 9 ms | 332 KB | Output is correct |
14 | Correct | 24 ms | 376 KB | Output is correct |
15 | Correct | 32 ms | 1268 KB | Output is correct |
16 | Execution timed out | 1085 ms | 660 KB | Time limit exceeded |
17 | Halted | 0 ms | 0 KB | - |