# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
84050 | 2018-11-12T14:02:12 Z | tjdgus4384 | 트리 (KOI16_treeM) | C++14 | 2000 ms | 33676 KB |
#include<cstdio> #include<vector> using namespace std; int pa[200001], g[200001]; vector<int> v[200001]; void spread(int x, int y) { for(int i = 0;i < v[x].size();i++) { if(g[v[x][i]] == g[x]) spread(v[x][i], y); } g[x] = y; } int main() { int n, q, x, b, c, d; scanf("%d %d", &n, &q); pa[1] = 1; g[1] = 1; for(int i = 2;i <= n;i++) { scanf("%d", &pa[i]); v[pa[i]].push_back(i); g[i] = 1; } for(int i = 1;i < n + q;i++) { scanf("%d", &x); if(!x) { scanf("%d", &b); spread(b, b); } else { scanf("%d %d", &c, &d); if(g[c] == g[d]) printf("YES\n"); else printf("NO\n"); } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5108 KB | Output is correct |
3 | Correct | 7 ms | 5108 KB | Output is correct |
4 | Correct | 7 ms | 5108 KB | Output is correct |
5 | Correct | 7 ms | 5144 KB | Output is correct |
6 | Correct | 7 ms | 5192 KB | Output is correct |
7 | Correct | 7 ms | 5192 KB | Output is correct |
8 | Correct | 7 ms | 5204 KB | Output is correct |
9 | Correct | 7 ms | 5204 KB | Output is correct |
10 | Correct | 9 ms | 5204 KB | Output is correct |
11 | Correct | 7 ms | 5268 KB | Output is correct |
12 | Correct | 6 ms | 5268 KB | Output is correct |
13 | Correct | 7 ms | 5316 KB | Output is correct |
14 | Correct | 7 ms | 5316 KB | Output is correct |
15 | Correct | 6 ms | 5316 KB | Output is correct |
16 | Correct | 7 ms | 5320 KB | Output is correct |
17 | Correct | 6 ms | 5436 KB | Output is correct |
18 | Correct | 7 ms | 5436 KB | Output is correct |
19 | Correct | 7 ms | 5436 KB | Output is correct |
20 | Correct | 6 ms | 5436 KB | Output is correct |
21 | Correct | 7 ms | 5436 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5108 KB | Output is correct |
3 | Correct | 7 ms | 5108 KB | Output is correct |
4 | Correct | 7 ms | 5108 KB | Output is correct |
5 | Correct | 7 ms | 5144 KB | Output is correct |
6 | Correct | 7 ms | 5192 KB | Output is correct |
7 | Correct | 7 ms | 5192 KB | Output is correct |
8 | Correct | 7 ms | 5204 KB | Output is correct |
9 | Correct | 7 ms | 5204 KB | Output is correct |
10 | Correct | 9 ms | 5204 KB | Output is correct |
11 | Correct | 7 ms | 5268 KB | Output is correct |
12 | Correct | 6 ms | 5268 KB | Output is correct |
13 | Correct | 7 ms | 5316 KB | Output is correct |
14 | Correct | 7 ms | 5316 KB | Output is correct |
15 | Correct | 6 ms | 5316 KB | Output is correct |
16 | Correct | 7 ms | 5320 KB | Output is correct |
17 | Correct | 6 ms | 5436 KB | Output is correct |
18 | Correct | 7 ms | 5436 KB | Output is correct |
19 | Correct | 7 ms | 5436 KB | Output is correct |
20 | Correct | 6 ms | 5436 KB | Output is correct |
21 | Correct | 7 ms | 5436 KB | Output is correct |
22 | Correct | 84 ms | 5964 KB | Output is correct |
23 | Correct | 86 ms | 5964 KB | Output is correct |
24 | Correct | 92 ms | 5964 KB | Output is correct |
25 | Correct | 93 ms | 5964 KB | Output is correct |
26 | Correct | 89 ms | 5964 KB | Output is correct |
27 | Correct | 91 ms | 6012 KB | Output is correct |
28 | Correct | 86 ms | 6064 KB | Output is correct |
29 | Correct | 87 ms | 6064 KB | Output is correct |
30 | Correct | 83 ms | 6184 KB | Output is correct |
31 | Correct | 85 ms | 6184 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 695 ms | 19244 KB | Output is correct |
2 | Correct | 780 ms | 20140 KB | Output is correct |
3 | Correct | 683 ms | 21544 KB | Output is correct |
4 | Correct | 750 ms | 21544 KB | Output is correct |
5 | Correct | 844 ms | 21544 KB | Output is correct |
6 | Correct | 699 ms | 23428 KB | Output is correct |
7 | Correct | 715 ms | 27460 KB | Output is correct |
8 | Execution timed out | 2061 ms | 33676 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5108 KB | Output is correct |
3 | Correct | 7 ms | 5108 KB | Output is correct |
4 | Correct | 7 ms | 5108 KB | Output is correct |
5 | Correct | 7 ms | 5144 KB | Output is correct |
6 | Correct | 7 ms | 5192 KB | Output is correct |
7 | Correct | 7 ms | 5192 KB | Output is correct |
8 | Correct | 7 ms | 5204 KB | Output is correct |
9 | Correct | 7 ms | 5204 KB | Output is correct |
10 | Correct | 9 ms | 5204 KB | Output is correct |
11 | Correct | 7 ms | 5268 KB | Output is correct |
12 | Correct | 6 ms | 5268 KB | Output is correct |
13 | Correct | 7 ms | 5316 KB | Output is correct |
14 | Correct | 7 ms | 5316 KB | Output is correct |
15 | Correct | 6 ms | 5316 KB | Output is correct |
16 | Correct | 7 ms | 5320 KB | Output is correct |
17 | Correct | 6 ms | 5436 KB | Output is correct |
18 | Correct | 7 ms | 5436 KB | Output is correct |
19 | Correct | 7 ms | 5436 KB | Output is correct |
20 | Correct | 6 ms | 5436 KB | Output is correct |
21 | Correct | 7 ms | 5436 KB | Output is correct |
22 | Correct | 84 ms | 5964 KB | Output is correct |
23 | Correct | 86 ms | 5964 KB | Output is correct |
24 | Correct | 92 ms | 5964 KB | Output is correct |
25 | Correct | 93 ms | 5964 KB | Output is correct |
26 | Correct | 89 ms | 5964 KB | Output is correct |
27 | Correct | 91 ms | 6012 KB | Output is correct |
28 | Correct | 86 ms | 6064 KB | Output is correct |
29 | Correct | 87 ms | 6064 KB | Output is correct |
30 | Correct | 83 ms | 6184 KB | Output is correct |
31 | Correct | 85 ms | 6184 KB | Output is correct |
32 | Correct | 695 ms | 19244 KB | Output is correct |
33 | Correct | 780 ms | 20140 KB | Output is correct |
34 | Correct | 683 ms | 21544 KB | Output is correct |
35 | Correct | 750 ms | 21544 KB | Output is correct |
36 | Correct | 844 ms | 21544 KB | Output is correct |
37 | Correct | 699 ms | 23428 KB | Output is correct |
38 | Correct | 715 ms | 27460 KB | Output is correct |
39 | Execution timed out | 2061 ms | 33676 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |