# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125383 | 2019-07-05T07:17:31 Z | khsoo01 | Long Mansion (JOI17_long_mansion) | C++11 | 447 ms | 45136 KB |
#include<bits/stdc++.h> using namespace std; const int N = 500005, L = 524288; int n, q, req[N], lst[N], rb[N], l[N], r[N]; vector<int> key[N]; struct segtree { int v[2*L]; void upd (int P, int V) { P += L; v[P] = V; P /= 2; while(P) { v[P] = min(v[2*P], v[2*P+1]); P /= 2; } } int bound (int P, int V) { P += L; while(P & (P+1)) { if(v[P] < V) break; P = (P+1)/2; } while(P < L) { if(v[2*P] < V) P = 2*P; else P = 2*P+1; } return P - L; } } seg; int main() { scanf("%d",&n); for(int i=1;i<n;i++) { scanf("%d",&req[i]); } for(int i=1;i<=n;i++) { int M, T; scanf("%d",&M); while(M--) { scanf("%d",&T); key[i].push_back(T); } } for(int i=1;i<=n;i++) { seg.upd(i, lst[req[i-1]]); for(auto &T : key[i]) lst[T] = i; } fill(lst, lst+1+n, n+1); for(int i=n;i>=1;i--) { rb[i] = lst[req[i]]; for(auto &T : key[i]) lst[T] = i; } vector<int> S; for(int i=1;i<=n;i++) { int L = i, R = seg.bound(i+1, L) - 1; while(!S.empty()) { if(rb[L-1] > R) break; L = S.back(); R = seg.bound(i+1, L) - 1; S.pop_back(); } l[i] = L, r[i] = R; S.push_back(L); } scanf("%d",&q); while(q--) { int S, E; scanf("%d%d",&S,&E); puts(l[S] <= E && E <= r[S] ? "YES" : "NO"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 12280 KB | Output is correct |
2 | Correct | 15 ms | 12408 KB | Output is correct |
3 | Correct | 16 ms | 12408 KB | Output is correct |
4 | Correct | 15 ms | 12408 KB | Output is correct |
5 | Correct | 16 ms | 12280 KB | Output is correct |
6 | Correct | 15 ms | 12280 KB | Output is correct |
7 | Correct | 15 ms | 12292 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 12280 KB | Output is correct |
2 | Correct | 15 ms | 12408 KB | Output is correct |
3 | Correct | 16 ms | 12408 KB | Output is correct |
4 | Correct | 15 ms | 12408 KB | Output is correct |
5 | Correct | 16 ms | 12280 KB | Output is correct |
6 | Correct | 15 ms | 12280 KB | Output is correct |
7 | Correct | 15 ms | 12292 KB | Output is correct |
8 | Correct | 142 ms | 13780 KB | Output is correct |
9 | Correct | 141 ms | 13864 KB | Output is correct |
10 | Correct | 144 ms | 14044 KB | Output is correct |
11 | Correct | 142 ms | 14200 KB | Output is correct |
12 | Correct | 133 ms | 14060 KB | Output is correct |
13 | Correct | 137 ms | 13944 KB | Output is correct |
14 | Correct | 139 ms | 14072 KB | Output is correct |
15 | Correct | 136 ms | 14072 KB | Output is correct |
16 | Correct | 132 ms | 14300 KB | Output is correct |
17 | Correct | 138 ms | 14048 KB | Output is correct |
18 | Correct | 140 ms | 14072 KB | Output is correct |
19 | Correct | 137 ms | 14072 KB | Output is correct |
20 | Correct | 135 ms | 14168 KB | Output is correct |
21 | Correct | 131 ms | 14364 KB | Output is correct |
22 | Correct | 138 ms | 14072 KB | Output is correct |
23 | Correct | 145 ms | 13944 KB | Output is correct |
24 | Correct | 143 ms | 13832 KB | Output is correct |
25 | Correct | 141 ms | 13816 KB | Output is correct |
26 | Correct | 141 ms | 13800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 272 ms | 20316 KB | Output is correct |
2 | Correct | 269 ms | 20344 KB | Output is correct |
3 | Correct | 270 ms | 20384 KB | Output is correct |
4 | Correct | 272 ms | 20344 KB | Output is correct |
5 | Correct | 276 ms | 20356 KB | Output is correct |
6 | Correct | 227 ms | 19960 KB | Output is correct |
7 | Correct | 218 ms | 19960 KB | Output is correct |
8 | Correct | 227 ms | 20208 KB | Output is correct |
9 | Correct | 222 ms | 20088 KB | Output is correct |
10 | Correct | 217 ms | 20088 KB | Output is correct |
11 | Correct | 219 ms | 20088 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 12280 KB | Output is correct |
2 | Correct | 15 ms | 12408 KB | Output is correct |
3 | Correct | 16 ms | 12408 KB | Output is correct |
4 | Correct | 15 ms | 12408 KB | Output is correct |
5 | Correct | 16 ms | 12280 KB | Output is correct |
6 | Correct | 15 ms | 12280 KB | Output is correct |
7 | Correct | 15 ms | 12292 KB | Output is correct |
8 | Correct | 142 ms | 13780 KB | Output is correct |
9 | Correct | 141 ms | 13864 KB | Output is correct |
10 | Correct | 144 ms | 14044 KB | Output is correct |
11 | Correct | 142 ms | 14200 KB | Output is correct |
12 | Correct | 133 ms | 14060 KB | Output is correct |
13 | Correct | 137 ms | 13944 KB | Output is correct |
14 | Correct | 139 ms | 14072 KB | Output is correct |
15 | Correct | 136 ms | 14072 KB | Output is correct |
16 | Correct | 132 ms | 14300 KB | Output is correct |
17 | Correct | 138 ms | 14048 KB | Output is correct |
18 | Correct | 140 ms | 14072 KB | Output is correct |
19 | Correct | 137 ms | 14072 KB | Output is correct |
20 | Correct | 135 ms | 14168 KB | Output is correct |
21 | Correct | 131 ms | 14364 KB | Output is correct |
22 | Correct | 138 ms | 14072 KB | Output is correct |
23 | Correct | 145 ms | 13944 KB | Output is correct |
24 | Correct | 143 ms | 13832 KB | Output is correct |
25 | Correct | 141 ms | 13816 KB | Output is correct |
26 | Correct | 141 ms | 13800 KB | Output is correct |
27 | Correct | 272 ms | 20316 KB | Output is correct |
28 | Correct | 269 ms | 20344 KB | Output is correct |
29 | Correct | 270 ms | 20384 KB | Output is correct |
30 | Correct | 272 ms | 20344 KB | Output is correct |
31 | Correct | 276 ms | 20356 KB | Output is correct |
32 | Correct | 227 ms | 19960 KB | Output is correct |
33 | Correct | 218 ms | 19960 KB | Output is correct |
34 | Correct | 227 ms | 20208 KB | Output is correct |
35 | Correct | 222 ms | 20088 KB | Output is correct |
36 | Correct | 217 ms | 20088 KB | Output is correct |
37 | Correct | 219 ms | 20088 KB | Output is correct |
38 | Correct | 424 ms | 38848 KB | Output is correct |
39 | Correct | 441 ms | 45136 KB | Output is correct |
40 | Correct | 390 ms | 32612 KB | Output is correct |
41 | Correct | 447 ms | 43304 KB | Output is correct |
42 | Correct | 232 ms | 20152 KB | Output is correct |
43 | Correct | 232 ms | 19832 KB | Output is correct |
44 | Correct | 328 ms | 25692 KB | Output is correct |
45 | Correct | 344 ms | 25720 KB | Output is correct |
46 | Correct | 333 ms | 25720 KB | Output is correct |
47 | Correct | 243 ms | 19832 KB | Output is correct |
48 | Correct | 238 ms | 19832 KB | Output is correct |
49 | Correct | 334 ms | 25596 KB | Output is correct |
50 | Correct | 361 ms | 25664 KB | Output is correct |
51 | Correct | 347 ms | 25864 KB | Output is correct |
52 | Correct | 292 ms | 25968 KB | Output is correct |
53 | Correct | 379 ms | 32048 KB | Output is correct |
54 | Correct | 436 ms | 38012 KB | Output is correct |
55 | Correct | 362 ms | 31952 KB | Output is correct |