# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89621 | 2018-12-17T15:46:47 Z | Vardanyan | Birthday gift (IZhO18_treearray) | C++14 | 4000 ms | 20712 KB |
#include <bits/stdc++.h> using namespace std; const int N = 2*1000*100+5; int a[N]; vector<int> g[N]; int colour[N]; int par[N]; void kaxel(int v,int p = -1){ par[v] = p; for(int i = 0;i<g[v].size();i++){ int to = g[v][i]; if(to == p) continue; kaxel(to,v); } } void dfs(int v,int p,int col){ colour[v] = col; for(int i = 0;i<g[v].size();i++){ int to = g[v][i]; if(to == p) continue; dfs(to,v,col); } } int main(){ int n,m,q; scanf("%d%d%d",&n,&m,&q); for(int i = 1;i<=n-1;i++){ int x,y; scanf("%d%d",&x,&y); g[x].push_back(y); g[y].push_back(x); } kaxel(1); for(int i = 1;i<=m;i++) scanf("%d",&a[i]); while(q--){ int tp; scanf("%d",&tp); if(tp == 1){ int pos,val; scanf("%d%d",&pos,&val); a[pos] = val; } else{ int l,r,v; scanf("%d%d%d",&l,&r,&v); for(int i = 1;i<=n;i++) colour[i] = 0; for(int i = 0;i<g[v].size();i++){ int to = g[v][i]; if(to!=par[v]) dfs(to,par[to],i+1); } bool f = false; for(int i = l;i<=r;i++){ if(v == a[i]){ printf("%d %d\n",i,i); f = true; break; } if(i == r) continue; if(colour[a[i]] && colour[a[i+1]] && colour[a[i]]!=colour[a[i+1]]){ printf("%d %d\n",i,i+1); f = true; break; } } if(f) continue; printf("-1 -1\n"); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | n=5 |
2 | Correct | 6 ms | 5116 KB | n=100 |
3 | Correct | 6 ms | 5160 KB | n=100 |
4 | Correct | 6 ms | 5276 KB | n=100 |
5 | Correct | 6 ms | 5276 KB | n=100 |
6 | Correct | 6 ms | 5276 KB | n=100 |
7 | Correct | 6 ms | 5276 KB | n=100 |
8 | Correct | 7 ms | 5348 KB | n=100 |
9 | Correct | 7 ms | 5348 KB | n=100 |
10 | Correct | 6 ms | 5348 KB | n=100 |
11 | Correct | 6 ms | 5348 KB | n=100 |
12 | Correct | 7 ms | 5348 KB | n=100 |
13 | Correct | 7 ms | 5348 KB | n=100 |
14 | Correct | 7 ms | 5348 KB | n=100 |
15 | Correct | 7 ms | 5348 KB | n=100 |
16 | Correct | 7 ms | 5348 KB | n=100 |
17 | Correct | 7 ms | 5348 KB | n=100 |
18 | Correct | 6 ms | 5348 KB | n=100 |
19 | Correct | 8 ms | 5456 KB | n=100 |
20 | Correct | 7 ms | 5456 KB | n=100 |
21 | Correct | 7 ms | 5456 KB | n=100 |
22 | Correct | 7 ms | 5456 KB | n=100 |
23 | Correct | 7 ms | 5456 KB | n=100 |
24 | Correct | 7 ms | 5456 KB | n=100 |
25 | Correct | 5 ms | 5456 KB | n=100 |
26 | Correct | 6 ms | 5456 KB | n=12 |
27 | Correct | 6 ms | 5456 KB | n=100 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | n=5 |
2 | Correct | 6 ms | 5116 KB | n=100 |
3 | Correct | 6 ms | 5160 KB | n=100 |
4 | Correct | 6 ms | 5276 KB | n=100 |
5 | Correct | 6 ms | 5276 KB | n=100 |
6 | Correct | 6 ms | 5276 KB | n=100 |
7 | Correct | 6 ms | 5276 KB | n=100 |
8 | Correct | 7 ms | 5348 KB | n=100 |
9 | Correct | 7 ms | 5348 KB | n=100 |
10 | Correct | 6 ms | 5348 KB | n=100 |
11 | Correct | 6 ms | 5348 KB | n=100 |
12 | Correct | 7 ms | 5348 KB | n=100 |
13 | Correct | 7 ms | 5348 KB | n=100 |
14 | Correct | 7 ms | 5348 KB | n=100 |
15 | Correct | 7 ms | 5348 KB | n=100 |
16 | Correct | 7 ms | 5348 KB | n=100 |
17 | Correct | 7 ms | 5348 KB | n=100 |
18 | Correct | 6 ms | 5348 KB | n=100 |
19 | Correct | 8 ms | 5456 KB | n=100 |
20 | Correct | 7 ms | 5456 KB | n=100 |
21 | Correct | 7 ms | 5456 KB | n=100 |
22 | Correct | 7 ms | 5456 KB | n=100 |
23 | Correct | 7 ms | 5456 KB | n=100 |
24 | Correct | 7 ms | 5456 KB | n=100 |
25 | Correct | 5 ms | 5456 KB | n=100 |
26 | Correct | 6 ms | 5456 KB | n=12 |
27 | Correct | 6 ms | 5456 KB | n=100 |
28 | Correct | 7 ms | 5456 KB | n=500 |
29 | Correct | 7 ms | 5564 KB | n=500 |
30 | Correct | 7 ms | 5596 KB | n=500 |
31 | Correct | 7 ms | 5612 KB | n=500 |
32 | Correct | 7 ms | 5612 KB | n=500 |
33 | Correct | 7 ms | 5656 KB | n=500 |
34 | Correct | 7 ms | 5688 KB | n=500 |
35 | Correct | 8 ms | 5716 KB | n=500 |
36 | Correct | 7 ms | 5716 KB | n=500 |
37 | Correct | 7 ms | 5716 KB | n=500 |
38 | Correct | 8 ms | 5716 KB | n=500 |
39 | Correct | 7 ms | 5768 KB | n=500 |
40 | Correct | 8 ms | 5908 KB | n=500 |
41 | Correct | 9 ms | 5908 KB | n=500 |
42 | Correct | 8 ms | 5908 KB | n=500 |
43 | Correct | 7 ms | 5908 KB | n=500 |
44 | Correct | 8 ms | 5908 KB | n=500 |
45 | Correct | 8 ms | 5908 KB | n=500 |
46 | Correct | 8 ms | 5908 KB | n=500 |
47 | Correct | 8 ms | 5908 KB | n=500 |
48 | Correct | 8 ms | 5908 KB | n=500 |
49 | Correct | 8 ms | 5920 KB | n=500 |
50 | Correct | 7 ms | 5920 KB | n=500 |
51 | Correct | 8 ms | 5928 KB | n=500 |
52 | Correct | 8 ms | 5952 KB | n=500 |
53 | Correct | 8 ms | 5968 KB | n=500 |
54 | Correct | 9 ms | 5972 KB | n=500 |
55 | Correct | 7 ms | 5972 KB | n=278 |
56 | Correct | 9 ms | 6004 KB | n=500 |
57 | Correct | 9 ms | 6016 KB | n=500 |
58 | Correct | 7 ms | 6032 KB | n=500 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | n=5 |
2 | Correct | 6 ms | 5116 KB | n=100 |
3 | Correct | 6 ms | 5160 KB | n=100 |
4 | Correct | 6 ms | 5276 KB | n=100 |
5 | Correct | 6 ms | 5276 KB | n=100 |
6 | Correct | 6 ms | 5276 KB | n=100 |
7 | Correct | 6 ms | 5276 KB | n=100 |
8 | Correct | 7 ms | 5348 KB | n=100 |
9 | Correct | 7 ms | 5348 KB | n=100 |
10 | Correct | 6 ms | 5348 KB | n=100 |
11 | Correct | 6 ms | 5348 KB | n=100 |
12 | Correct | 7 ms | 5348 KB | n=100 |
13 | Correct | 7 ms | 5348 KB | n=100 |
14 | Correct | 7 ms | 5348 KB | n=100 |
15 | Correct | 7 ms | 5348 KB | n=100 |
16 | Correct | 7 ms | 5348 KB | n=100 |
17 | Correct | 7 ms | 5348 KB | n=100 |
18 | Correct | 6 ms | 5348 KB | n=100 |
19 | Correct | 8 ms | 5456 KB | n=100 |
20 | Correct | 7 ms | 5456 KB | n=100 |
21 | Correct | 7 ms | 5456 KB | n=100 |
22 | Correct | 7 ms | 5456 KB | n=100 |
23 | Correct | 7 ms | 5456 KB | n=100 |
24 | Correct | 7 ms | 5456 KB | n=100 |
25 | Correct | 5 ms | 5456 KB | n=100 |
26 | Correct | 6 ms | 5456 KB | n=12 |
27 | Correct | 6 ms | 5456 KB | n=100 |
28 | Correct | 7 ms | 5456 KB | n=500 |
29 | Correct | 7 ms | 5564 KB | n=500 |
30 | Correct | 7 ms | 5596 KB | n=500 |
31 | Correct | 7 ms | 5612 KB | n=500 |
32 | Correct | 7 ms | 5612 KB | n=500 |
33 | Correct | 7 ms | 5656 KB | n=500 |
34 | Correct | 7 ms | 5688 KB | n=500 |
35 | Correct | 8 ms | 5716 KB | n=500 |
36 | Correct | 7 ms | 5716 KB | n=500 |
37 | Correct | 7 ms | 5716 KB | n=500 |
38 | Correct | 8 ms | 5716 KB | n=500 |
39 | Correct | 7 ms | 5768 KB | n=500 |
40 | Correct | 8 ms | 5908 KB | n=500 |
41 | Correct | 9 ms | 5908 KB | n=500 |
42 | Correct | 8 ms | 5908 KB | n=500 |
43 | Correct | 7 ms | 5908 KB | n=500 |
44 | Correct | 8 ms | 5908 KB | n=500 |
45 | Correct | 8 ms | 5908 KB | n=500 |
46 | Correct | 8 ms | 5908 KB | n=500 |
47 | Correct | 8 ms | 5908 KB | n=500 |
48 | Correct | 8 ms | 5908 KB | n=500 |
49 | Correct | 8 ms | 5920 KB | n=500 |
50 | Correct | 7 ms | 5920 KB | n=500 |
51 | Correct | 8 ms | 5928 KB | n=500 |
52 | Correct | 8 ms | 5952 KB | n=500 |
53 | Correct | 8 ms | 5968 KB | n=500 |
54 | Correct | 9 ms | 5972 KB | n=500 |
55 | Correct | 7 ms | 5972 KB | n=278 |
56 | Correct | 9 ms | 6004 KB | n=500 |
57 | Correct | 9 ms | 6016 KB | n=500 |
58 | Correct | 7 ms | 6032 KB | n=500 |
59 | Correct | 25 ms | 6052 KB | n=2000 |
60 | Correct | 30 ms | 6304 KB | n=2000 |
61 | Correct | 34 ms | 6316 KB | n=2000 |
62 | Correct | 28 ms | 6460 KB | n=2000 |
63 | Correct | 25 ms | 6460 KB | n=2000 |
64 | Correct | 29 ms | 6460 KB | n=2000 |
65 | Correct | 25 ms | 6460 KB | n=2000 |
66 | Correct | 29 ms | 6572 KB | n=2000 |
67 | Correct | 25 ms | 6580 KB | n=2000 |
68 | Correct | 27 ms | 6668 KB | n=2000 |
69 | Correct | 31 ms | 6824 KB | n=2000 |
70 | Correct | 31 ms | 6824 KB | n=2000 |
71 | Correct | 33 ms | 6824 KB | n=2000 |
72 | Correct | 30 ms | 6824 KB | n=2000 |
73 | Correct | 28 ms | 6824 KB | n=2000 |
74 | Correct | 20 ms | 6992 KB | n=1844 |
75 | Correct | 31 ms | 7032 KB | n=2000 |
76 | Correct | 20 ms | 7032 KB | n=2000 |
77 | Correct | 30 ms | 7032 KB | n=2000 |
78 | Correct | 26 ms | 7068 KB | n=2000 |
79 | Correct | 25 ms | 7124 KB | n=2000 |
80 | Correct | 35 ms | 7300 KB | n=2000 |
81 | Correct | 33 ms | 7356 KB | n=2000 |
82 | Correct | 25 ms | 7356 KB | n=2000 |
83 | Correct | 27 ms | 7480 KB | n=2000 |
84 | Correct | 11 ms | 7492 KB | n=2000 |
85 | Correct | 18 ms | 7568 KB | n=2000 |
86 | Correct | 17 ms | 7608 KB | n=2000 |
87 | Correct | 10 ms | 7608 KB | n=2000 |
88 | Correct | 48 ms | 7732 KB | n=2000 |
89 | Correct | 44 ms | 7788 KB | n=2000 |
90 | Correct | 45 ms | 7844 KB | n=2000 |
91 | Correct | 13 ms | 7844 KB | n=2000 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5112 KB | n=5 |
2 | Correct | 6 ms | 5116 KB | n=100 |
3 | Correct | 6 ms | 5160 KB | n=100 |
4 | Correct | 6 ms | 5276 KB | n=100 |
5 | Correct | 6 ms | 5276 KB | n=100 |
6 | Correct | 6 ms | 5276 KB | n=100 |
7 | Correct | 6 ms | 5276 KB | n=100 |
8 | Correct | 7 ms | 5348 KB | n=100 |
9 | Correct | 7 ms | 5348 KB | n=100 |
10 | Correct | 6 ms | 5348 KB | n=100 |
11 | Correct | 6 ms | 5348 KB | n=100 |
12 | Correct | 7 ms | 5348 KB | n=100 |
13 | Correct | 7 ms | 5348 KB | n=100 |
14 | Correct | 7 ms | 5348 KB | n=100 |
15 | Correct | 7 ms | 5348 KB | n=100 |
16 | Correct | 7 ms | 5348 KB | n=100 |
17 | Correct | 7 ms | 5348 KB | n=100 |
18 | Correct | 6 ms | 5348 KB | n=100 |
19 | Correct | 8 ms | 5456 KB | n=100 |
20 | Correct | 7 ms | 5456 KB | n=100 |
21 | Correct | 7 ms | 5456 KB | n=100 |
22 | Correct | 7 ms | 5456 KB | n=100 |
23 | Correct | 7 ms | 5456 KB | n=100 |
24 | Correct | 7 ms | 5456 KB | n=100 |
25 | Correct | 5 ms | 5456 KB | n=100 |
26 | Correct | 6 ms | 5456 KB | n=12 |
27 | Correct | 6 ms | 5456 KB | n=100 |
28 | Correct | 7 ms | 5456 KB | n=500 |
29 | Correct | 7 ms | 5564 KB | n=500 |
30 | Correct | 7 ms | 5596 KB | n=500 |
31 | Correct | 7 ms | 5612 KB | n=500 |
32 | Correct | 7 ms | 5612 KB | n=500 |
33 | Correct | 7 ms | 5656 KB | n=500 |
34 | Correct | 7 ms | 5688 KB | n=500 |
35 | Correct | 8 ms | 5716 KB | n=500 |
36 | Correct | 7 ms | 5716 KB | n=500 |
37 | Correct | 7 ms | 5716 KB | n=500 |
38 | Correct | 8 ms | 5716 KB | n=500 |
39 | Correct | 7 ms | 5768 KB | n=500 |
40 | Correct | 8 ms | 5908 KB | n=500 |
41 | Correct | 9 ms | 5908 KB | n=500 |
42 | Correct | 8 ms | 5908 KB | n=500 |
43 | Correct | 7 ms | 5908 KB | n=500 |
44 | Correct | 8 ms | 5908 KB | n=500 |
45 | Correct | 8 ms | 5908 KB | n=500 |
46 | Correct | 8 ms | 5908 KB | n=500 |
47 | Correct | 8 ms | 5908 KB | n=500 |
48 | Correct | 8 ms | 5908 KB | n=500 |
49 | Correct | 8 ms | 5920 KB | n=500 |
50 | Correct | 7 ms | 5920 KB | n=500 |
51 | Correct | 8 ms | 5928 KB | n=500 |
52 | Correct | 8 ms | 5952 KB | n=500 |
53 | Correct | 8 ms | 5968 KB | n=500 |
54 | Correct | 9 ms | 5972 KB | n=500 |
55 | Correct | 7 ms | 5972 KB | n=278 |
56 | Correct | 9 ms | 6004 KB | n=500 |
57 | Correct | 9 ms | 6016 KB | n=500 |
58 | Correct | 7 ms | 6032 KB | n=500 |
59 | Correct | 25 ms | 6052 KB | n=2000 |
60 | Correct | 30 ms | 6304 KB | n=2000 |
61 | Correct | 34 ms | 6316 KB | n=2000 |
62 | Correct | 28 ms | 6460 KB | n=2000 |
63 | Correct | 25 ms | 6460 KB | n=2000 |
64 | Correct | 29 ms | 6460 KB | n=2000 |
65 | Correct | 25 ms | 6460 KB | n=2000 |
66 | Correct | 29 ms | 6572 KB | n=2000 |
67 | Correct | 25 ms | 6580 KB | n=2000 |
68 | Correct | 27 ms | 6668 KB | n=2000 |
69 | Correct | 31 ms | 6824 KB | n=2000 |
70 | Correct | 31 ms | 6824 KB | n=2000 |
71 | Correct | 33 ms | 6824 KB | n=2000 |
72 | Correct | 30 ms | 6824 KB | n=2000 |
73 | Correct | 28 ms | 6824 KB | n=2000 |
74 | Correct | 20 ms | 6992 KB | n=1844 |
75 | Correct | 31 ms | 7032 KB | n=2000 |
76 | Correct | 20 ms | 7032 KB | n=2000 |
77 | Correct | 30 ms | 7032 KB | n=2000 |
78 | Correct | 26 ms | 7068 KB | n=2000 |
79 | Correct | 25 ms | 7124 KB | n=2000 |
80 | Correct | 35 ms | 7300 KB | n=2000 |
81 | Correct | 33 ms | 7356 KB | n=2000 |
82 | Correct | 25 ms | 7356 KB | n=2000 |
83 | Correct | 27 ms | 7480 KB | n=2000 |
84 | Correct | 11 ms | 7492 KB | n=2000 |
85 | Correct | 18 ms | 7568 KB | n=2000 |
86 | Correct | 17 ms | 7608 KB | n=2000 |
87 | Correct | 10 ms | 7608 KB | n=2000 |
88 | Correct | 48 ms | 7732 KB | n=2000 |
89 | Correct | 44 ms | 7788 KB | n=2000 |
90 | Correct | 45 ms | 7844 KB | n=2000 |
91 | Correct | 13 ms | 7844 KB | n=2000 |
92 | Execution timed out | 4065 ms | 20712 KB | Time limit exceeded |
93 | Halted | 0 ms | 0 KB | - |