# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
125379 | 2019-07-05T07:12:10 Z | khsoo01 | Long Mansion (JOI17_long_mansion) | C++11 | 450 ms | 45176 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()) { int C = S.back(); if(rb[L-1] > R) break; S.pop_back(); L = C; R = seg.bound(i+1, L) - 1; } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 12280 KB | Output is correct |
2 | Correct | 16 ms | 12408 KB | Output is correct |
3 | Correct | 18 ms | 12664 KB | Output is correct |
4 | Correct | 18 ms | 12280 KB | Output is correct |
5 | Correct | 15 ms | 12280 KB | Output is correct |
6 | Correct | 16 ms | 12280 KB | Output is correct |
7 | Correct | 15 ms | 12280 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 12280 KB | Output is correct |
2 | Correct | 16 ms | 12408 KB | Output is correct |
3 | Correct | 18 ms | 12664 KB | Output is correct |
4 | Correct | 18 ms | 12280 KB | Output is correct |
5 | Correct | 15 ms | 12280 KB | Output is correct |
6 | Correct | 16 ms | 12280 KB | Output is correct |
7 | Correct | 15 ms | 12280 KB | Output is correct |
8 | Correct | 143 ms | 13816 KB | Output is correct |
9 | Correct | 145 ms | 13856 KB | Output is correct |
10 | Correct | 147 ms | 14072 KB | Output is correct |
11 | Correct | 144 ms | 14328 KB | Output is correct |
12 | Correct | 141 ms | 13944 KB | Output is correct |
13 | Correct | 138 ms | 13944 KB | Output is correct |
14 | Correct | 139 ms | 13944 KB | Output is correct |
15 | Correct | 137 ms | 14072 KB | Output is correct |
16 | Correct | 132 ms | 14312 KB | Output is correct |
17 | Correct | 138 ms | 14072 KB | Output is correct |
18 | Correct | 139 ms | 14152 KB | Output is correct |
19 | Correct | 140 ms | 14072 KB | Output is correct |
20 | Correct | 134 ms | 14272 KB | Output is correct |
21 | Correct | 130 ms | 14220 KB | Output is correct |
22 | Correct | 139 ms | 14292 KB | Output is correct |
23 | Correct | 140 ms | 13816 KB | Output is correct |
24 | Correct | 139 ms | 13920 KB | Output is correct |
25 | Correct | 140 ms | 13944 KB | Output is correct |
26 | Correct | 140 ms | 13820 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 275 ms | 20336 KB | Output is correct |
2 | Correct | 272 ms | 20320 KB | Output is correct |
3 | Correct | 268 ms | 20344 KB | Output is correct |
4 | Correct | 278 ms | 20504 KB | Output is correct |
5 | Correct | 271 ms | 20344 KB | Output is correct |
6 | Correct | 249 ms | 19944 KB | Output is correct |
7 | Correct | 240 ms | 19960 KB | Output is correct |
8 | Correct | 219 ms | 19960 KB | Output is correct |
9 | Correct | 219 ms | 20100 KB | Output is correct |
10 | Correct | 219 ms | 20000 KB | Output is correct |
11 | Correct | 235 ms | 20088 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 12280 KB | Output is correct |
2 | Correct | 16 ms | 12408 KB | Output is correct |
3 | Correct | 18 ms | 12664 KB | Output is correct |
4 | Correct | 18 ms | 12280 KB | Output is correct |
5 | Correct | 15 ms | 12280 KB | Output is correct |
6 | Correct | 16 ms | 12280 KB | Output is correct |
7 | Correct | 15 ms | 12280 KB | Output is correct |
8 | Correct | 143 ms | 13816 KB | Output is correct |
9 | Correct | 145 ms | 13856 KB | Output is correct |
10 | Correct | 147 ms | 14072 KB | Output is correct |
11 | Correct | 144 ms | 14328 KB | Output is correct |
12 | Correct | 141 ms | 13944 KB | Output is correct |
13 | Correct | 138 ms | 13944 KB | Output is correct |
14 | Correct | 139 ms | 13944 KB | Output is correct |
15 | Correct | 137 ms | 14072 KB | Output is correct |
16 | Correct | 132 ms | 14312 KB | Output is correct |
17 | Correct | 138 ms | 14072 KB | Output is correct |
18 | Correct | 139 ms | 14152 KB | Output is correct |
19 | Correct | 140 ms | 14072 KB | Output is correct |
20 | Correct | 134 ms | 14272 KB | Output is correct |
21 | Correct | 130 ms | 14220 KB | Output is correct |
22 | Correct | 139 ms | 14292 KB | Output is correct |
23 | Correct | 140 ms | 13816 KB | Output is correct |
24 | Correct | 139 ms | 13920 KB | Output is correct |
25 | Correct | 140 ms | 13944 KB | Output is correct |
26 | Correct | 140 ms | 13820 KB | Output is correct |
27 | Correct | 275 ms | 20336 KB | Output is correct |
28 | Correct | 272 ms | 20320 KB | Output is correct |
29 | Correct | 268 ms | 20344 KB | Output is correct |
30 | Correct | 278 ms | 20504 KB | Output is correct |
31 | Correct | 271 ms | 20344 KB | Output is correct |
32 | Correct | 249 ms | 19944 KB | Output is correct |
33 | Correct | 240 ms | 19960 KB | Output is correct |
34 | Correct | 219 ms | 19960 KB | Output is correct |
35 | Correct | 219 ms | 20100 KB | Output is correct |
36 | Correct | 219 ms | 20000 KB | Output is correct |
37 | Correct | 235 ms | 20088 KB | Output is correct |
38 | Correct | 429 ms | 38968 KB | Output is correct |
39 | Correct | 445 ms | 45176 KB | Output is correct |
40 | Correct | 389 ms | 32788 KB | Output is correct |
41 | Correct | 450 ms | 43420 KB | Output is correct |
42 | Correct | 237 ms | 20088 KB | Output is correct |
43 | Correct | 234 ms | 19888 KB | Output is correct |
44 | Correct | 327 ms | 25720 KB | Output is correct |
45 | Correct | 331 ms | 25728 KB | Output is correct |
46 | Correct | 337 ms | 25720 KB | Output is correct |
47 | Correct | 243 ms | 19960 KB | Output is correct |
48 | Correct | 236 ms | 19832 KB | Output is correct |
49 | Correct | 356 ms | 25720 KB | Output is correct |
50 | Correct | 336 ms | 25592 KB | Output is correct |
51 | Correct | 377 ms | 25976 KB | Output is correct |
52 | Correct | 299 ms | 26020 KB | Output is correct |
53 | Correct | 376 ms | 32084 KB | Output is correct |
54 | Correct | 434 ms | 38112 KB | Output is correct |
55 | Correct | 372 ms | 31984 KB | Output is correct |