# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
60385 | 2018-07-24T04:35:36 Z | 김세빈(#1743) | Long Mansion (JOI17_long_mansion) | C++11 | 913 ms | 126276 KB |
#include <bits/stdc++.h> using namespace std; vector <int> K[505050]; int T[505050]; int L[505050], R[505050], X[505050], Y[505050]; bool C[505050]; int n; void get_keys(int p) { for(int t: K[p]) C[t] = 1; } void init_keys(int p) { for(int t: K[p]) C[t] = 0; } void dnc(int s, int e) { if(s == e){ L[s] = R[s] = s; return; } int i, l, r, f, m = s + e >> 1; dnc(s, m); dnc(m + 1, e); for(i=l=r=m; i>=s; i--){ get_keys(i); for(f=1; f; ){ for(f=0; r<e && C[T[r]]; r++) get_keys(r + 1), f = 1; for(; l>s && C[T[l-1]]; l--) get_keys(l - 1), f = 1; } X[i] = l, Y[i] = r; } for(i=s; i<=m; i++){ if(R[i] == m){ R[i] = Y[L[i]]; L[i] = X[L[i]]; } } for(i=s; i<=e; i++) init_keys(i); for(i=l=r=m+1; i<=e; i++){ get_keys(i); for(f=1; f; ){ for(f=0; r<e && C[T[r]]; r++) get_keys(r + 1), f = 1; for(; l>s && C[T[l-1]]; l--) get_keys(l - 1), f = 1; } X[i] = l, Y[i] = r; } for(i=e; i>m; i--){ if(L[i] == m + 1){ L[i] = X[R[i]]; R[i] = Y[R[i]]; } } for(i=s; i<=e; i++) init_keys(i); } int main() { int q, i, a, b; scanf("%d", &n); for(i=1; i<n; i++){ scanf("%d", T+i); } for(i=1; i<=n; i++){ scanf("%d", &a); for(; a--; ){ scanf("%d", &b); K[i].push_back(b); } } dnc(1, n); scanf("%d", &q); for(; q--; ){ scanf("%d%d", &a, &b); if(L[a] <= b && b <= R[a]) printf("YES\n"); else printf("NO\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 12408 KB | Output is correct |
2 | Correct | 19 ms | 12600 KB | Output is correct |
3 | Correct | 19 ms | 12832 KB | Output is correct |
4 | Correct | 20 ms | 12832 KB | Output is correct |
5 | Correct | 17 ms | 12832 KB | Output is correct |
6 | Correct | 21 ms | 12848 KB | Output is correct |
7 | Correct | 21 ms | 12924 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 12408 KB | Output is correct |
2 | Correct | 19 ms | 12600 KB | Output is correct |
3 | Correct | 19 ms | 12832 KB | Output is correct |
4 | Correct | 20 ms | 12832 KB | Output is correct |
5 | Correct | 17 ms | 12832 KB | Output is correct |
6 | Correct | 21 ms | 12848 KB | Output is correct |
7 | Correct | 21 ms | 12924 KB | Output is correct |
8 | Correct | 217 ms | 18880 KB | Output is correct |
9 | Correct | 219 ms | 21796 KB | Output is correct |
10 | Correct | 184 ms | 22116 KB | Output is correct |
11 | Correct | 221 ms | 22268 KB | Output is correct |
12 | Correct | 197 ms | 22268 KB | Output is correct |
13 | Correct | 199 ms | 22268 KB | Output is correct |
14 | Correct | 171 ms | 22268 KB | Output is correct |
15 | Correct | 223 ms | 22268 KB | Output is correct |
16 | Correct | 166 ms | 22296 KB | Output is correct |
17 | Correct | 221 ms | 22296 KB | Output is correct |
18 | Correct | 178 ms | 22296 KB | Output is correct |
19 | Correct | 209 ms | 22312 KB | Output is correct |
20 | Correct | 179 ms | 22312 KB | Output is correct |
21 | Correct | 215 ms | 22356 KB | Output is correct |
22 | Correct | 167 ms | 22356 KB | Output is correct |
23 | Correct | 214 ms | 22356 KB | Output is correct |
24 | Correct | 217 ms | 22356 KB | Output is correct |
25 | Correct | 173 ms | 22356 KB | Output is correct |
26 | Correct | 205 ms | 22356 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 519 ms | 27772 KB | Output is correct |
2 | Correct | 463 ms | 27800 KB | Output is correct |
3 | Correct | 452 ms | 27800 KB | Output is correct |
4 | Correct | 532 ms | 27800 KB | Output is correct |
5 | Correct | 600 ms | 27896 KB | Output is correct |
6 | Correct | 401 ms | 27896 KB | Output is correct |
7 | Correct | 350 ms | 27896 KB | Output is correct |
8 | Correct | 388 ms | 27896 KB | Output is correct |
9 | Correct | 347 ms | 27896 KB | Output is correct |
10 | Correct | 388 ms | 27896 KB | Output is correct |
11 | Correct | 348 ms | 27896 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 12408 KB | Output is correct |
2 | Correct | 19 ms | 12600 KB | Output is correct |
3 | Correct | 19 ms | 12832 KB | Output is correct |
4 | Correct | 20 ms | 12832 KB | Output is correct |
5 | Correct | 17 ms | 12832 KB | Output is correct |
6 | Correct | 21 ms | 12848 KB | Output is correct |
7 | Correct | 21 ms | 12924 KB | Output is correct |
8 | Correct | 217 ms | 18880 KB | Output is correct |
9 | Correct | 219 ms | 21796 KB | Output is correct |
10 | Correct | 184 ms | 22116 KB | Output is correct |
11 | Correct | 221 ms | 22268 KB | Output is correct |
12 | Correct | 197 ms | 22268 KB | Output is correct |
13 | Correct | 199 ms | 22268 KB | Output is correct |
14 | Correct | 171 ms | 22268 KB | Output is correct |
15 | Correct | 223 ms | 22268 KB | Output is correct |
16 | Correct | 166 ms | 22296 KB | Output is correct |
17 | Correct | 221 ms | 22296 KB | Output is correct |
18 | Correct | 178 ms | 22296 KB | Output is correct |
19 | Correct | 209 ms | 22312 KB | Output is correct |
20 | Correct | 179 ms | 22312 KB | Output is correct |
21 | Correct | 215 ms | 22356 KB | Output is correct |
22 | Correct | 167 ms | 22356 KB | Output is correct |
23 | Correct | 214 ms | 22356 KB | Output is correct |
24 | Correct | 217 ms | 22356 KB | Output is correct |
25 | Correct | 173 ms | 22356 KB | Output is correct |
26 | Correct | 205 ms | 22356 KB | Output is correct |
27 | Correct | 519 ms | 27772 KB | Output is correct |
28 | Correct | 463 ms | 27800 KB | Output is correct |
29 | Correct | 452 ms | 27800 KB | Output is correct |
30 | Correct | 532 ms | 27800 KB | Output is correct |
31 | Correct | 600 ms | 27896 KB | Output is correct |
32 | Correct | 401 ms | 27896 KB | Output is correct |
33 | Correct | 350 ms | 27896 KB | Output is correct |
34 | Correct | 388 ms | 27896 KB | Output is correct |
35 | Correct | 347 ms | 27896 KB | Output is correct |
36 | Correct | 388 ms | 27896 KB | Output is correct |
37 | Correct | 348 ms | 27896 KB | Output is correct |
38 | Correct | 792 ms | 42152 KB | Output is correct |
39 | Correct | 815 ms | 47416 KB | Output is correct |
40 | Correct | 771 ms | 47416 KB | Output is correct |
41 | Correct | 913 ms | 47484 KB | Output is correct |
42 | Correct | 447 ms | 47484 KB | Output is correct |
43 | Correct | 353 ms | 47484 KB | Output is correct |
44 | Correct | 488 ms | 47484 KB | Output is correct |
45 | Correct | 585 ms | 47484 KB | Output is correct |
46 | Correct | 615 ms | 47484 KB | Output is correct |
47 | Correct | 449 ms | 47484 KB | Output is correct |
48 | Correct | 340 ms | 47484 KB | Output is correct |
49 | Correct | 673 ms | 57068 KB | Output is correct |
50 | Correct | 614 ms | 67256 KB | Output is correct |
51 | Correct | 633 ms | 77840 KB | Output is correct |
52 | Correct | 553 ms | 86800 KB | Output is correct |
53 | Correct | 597 ms | 102836 KB | Output is correct |
54 | Correct | 626 ms | 120512 KB | Output is correct |
55 | Correct | 509 ms | 126276 KB | Output is correct |