# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
197684 | 2020-01-22T09:58:12 Z | dennisstar | Long Mansion (JOI17_long_mansion) | C++17 | 552 ms | 56572 KB |
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #define fi first #define se second #define ryan bear #define sq(X) ((X)*(X)) #define eb emplace_back #define all(V) (V).begin(), (V).end() #define unq(V) (V).erase(unique(all(V)), (V).end()) using namespace std; typedef long long ll; typedef vector<ll> vlm; typedef vector<int> vim; typedef pair<ll, ll> pll; typedef pair<int, int> pii; int N, Q; vim C, B, A[500010], pos[500010]; vim l, r; int Xk, Yk, lb; inline bool Find(int L, int R, int X) { lb=lower_bound(all(pos[X]), L)-pos[X].begin(); return (lb<pos[X].size()&&pos[X][lb]<=R); } int main() { scanf("%d", &N); C.resize(N); B.resize(N+1); l.resize(N+1); r.resize(N+1); for (int i=1; i<N; i++) scanf("%d", &C[i]); for (int i=1; i<=N; i++) { scanf("%d", &B[i]); A[i].resize(B[i]); for (auto &j:A[i]) scanf("%d", &j); for (auto &j:A[i]) pos[j].eb(i); } for (int i=1; i<=N; i++) { l[i]=r[i]=i; for (int fl; ; ) { fl=0; if (l[i]>1 && Find(l[i], r[i], C[l[i]-1])) { r[i]=max(r[i], r[l[i]-1]); l[i]=l[l[i]-1]; fl=1; } else if (r[i]<N && Find(l[i], r[i], C[r[i]])) { r[i]++; fl=1; } if (!fl) break; } } scanf("%d", &Q); while (Q--) { scanf("%d %d", &Xk, &Yk); if (l[Xk]<=Yk&&Yk<=r[Xk]) puts("YES"); else puts("NO"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 23928 KB | Output is correct |
2 | Correct | 27 ms | 23996 KB | Output is correct |
3 | Correct | 28 ms | 24056 KB | Output is correct |
4 | Correct | 31 ms | 23900 KB | Output is correct |
5 | Correct | 27 ms | 23928 KB | Output is correct |
6 | Correct | 27 ms | 24056 KB | Output is correct |
7 | Correct | 26 ms | 23928 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 23928 KB | Output is correct |
2 | Correct | 27 ms | 23996 KB | Output is correct |
3 | Correct | 28 ms | 24056 KB | Output is correct |
4 | Correct | 31 ms | 23900 KB | Output is correct |
5 | Correct | 27 ms | 23928 KB | Output is correct |
6 | Correct | 27 ms | 24056 KB | Output is correct |
7 | Correct | 26 ms | 23928 KB | Output is correct |
8 | Correct | 155 ms | 25584 KB | Output is correct |
9 | Correct | 154 ms | 25436 KB | Output is correct |
10 | Correct | 157 ms | 25732 KB | Output is correct |
11 | Correct | 156 ms | 26076 KB | Output is correct |
12 | Correct | 146 ms | 25592 KB | Output is correct |
13 | Correct | 151 ms | 25976 KB | Output is correct |
14 | Correct | 151 ms | 25816 KB | Output is correct |
15 | Correct | 149 ms | 25720 KB | Output is correct |
16 | Correct | 152 ms | 26000 KB | Output is correct |
17 | Correct | 151 ms | 25696 KB | Output is correct |
18 | Correct | 151 ms | 25740 KB | Output is correct |
19 | Correct | 150 ms | 25724 KB | Output is correct |
20 | Correct | 148 ms | 25968 KB | Output is correct |
21 | Correct | 145 ms | 25936 KB | Output is correct |
22 | Correct | 149 ms | 25720 KB | Output is correct |
23 | Correct | 151 ms | 25620 KB | Output is correct |
24 | Correct | 151 ms | 25592 KB | Output is correct |
25 | Correct | 150 ms | 25592 KB | Output is correct |
26 | Correct | 151 ms | 25580 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 290 ms | 33112 KB | Output is correct |
2 | Correct | 284 ms | 32532 KB | Output is correct |
3 | Correct | 275 ms | 32592 KB | Output is correct |
4 | Correct | 289 ms | 32632 KB | Output is correct |
5 | Correct | 292 ms | 32932 KB | Output is correct |
6 | Correct | 264 ms | 31864 KB | Output is correct |
7 | Correct | 227 ms | 31992 KB | Output is correct |
8 | Correct | 223 ms | 31992 KB | Output is correct |
9 | Correct | 241 ms | 31988 KB | Output is correct |
10 | Correct | 224 ms | 32120 KB | Output is correct |
11 | Correct | 225 ms | 31992 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 23928 KB | Output is correct |
2 | Correct | 27 ms | 23996 KB | Output is correct |
3 | Correct | 28 ms | 24056 KB | Output is correct |
4 | Correct | 31 ms | 23900 KB | Output is correct |
5 | Correct | 27 ms | 23928 KB | Output is correct |
6 | Correct | 27 ms | 24056 KB | Output is correct |
7 | Correct | 26 ms | 23928 KB | Output is correct |
8 | Correct | 155 ms | 25584 KB | Output is correct |
9 | Correct | 154 ms | 25436 KB | Output is correct |
10 | Correct | 157 ms | 25732 KB | Output is correct |
11 | Correct | 156 ms | 26076 KB | Output is correct |
12 | Correct | 146 ms | 25592 KB | Output is correct |
13 | Correct | 151 ms | 25976 KB | Output is correct |
14 | Correct | 151 ms | 25816 KB | Output is correct |
15 | Correct | 149 ms | 25720 KB | Output is correct |
16 | Correct | 152 ms | 26000 KB | Output is correct |
17 | Correct | 151 ms | 25696 KB | Output is correct |
18 | Correct | 151 ms | 25740 KB | Output is correct |
19 | Correct | 150 ms | 25724 KB | Output is correct |
20 | Correct | 148 ms | 25968 KB | Output is correct |
21 | Correct | 145 ms | 25936 KB | Output is correct |
22 | Correct | 149 ms | 25720 KB | Output is correct |
23 | Correct | 151 ms | 25620 KB | Output is correct |
24 | Correct | 151 ms | 25592 KB | Output is correct |
25 | Correct | 150 ms | 25592 KB | Output is correct |
26 | Correct | 151 ms | 25580 KB | Output is correct |
27 | Correct | 290 ms | 33112 KB | Output is correct |
28 | Correct | 284 ms | 32532 KB | Output is correct |
29 | Correct | 275 ms | 32592 KB | Output is correct |
30 | Correct | 289 ms | 32632 KB | Output is correct |
31 | Correct | 292 ms | 32932 KB | Output is correct |
32 | Correct | 264 ms | 31864 KB | Output is correct |
33 | Correct | 227 ms | 31992 KB | Output is correct |
34 | Correct | 223 ms | 31992 KB | Output is correct |
35 | Correct | 241 ms | 31988 KB | Output is correct |
36 | Correct | 224 ms | 32120 KB | Output is correct |
37 | Correct | 225 ms | 31992 KB | Output is correct |
38 | Correct | 494 ms | 47544 KB | Output is correct |
39 | Correct | 489 ms | 51888 KB | Output is correct |
40 | Correct | 421 ms | 42700 KB | Output is correct |
41 | Correct | 552 ms | 51452 KB | Output is correct |
42 | Correct | 293 ms | 32580 KB | Output is correct |
43 | Correct | 280 ms | 32108 KB | Output is correct |
44 | Correct | 407 ms | 38632 KB | Output is correct |
45 | Correct | 412 ms | 39176 KB | Output is correct |
46 | Correct | 413 ms | 39176 KB | Output is correct |
47 | Correct | 275 ms | 32704 KB | Output is correct |
48 | Correct | 273 ms | 32248 KB | Output is correct |
49 | Correct | 406 ms | 38144 KB | Output is correct |
50 | Correct | 420 ms | 38392 KB | Output is correct |
51 | Correct | 423 ms | 39416 KB | Output is correct |
52 | Correct | 323 ms | 41056 KB | Output is correct |
53 | Correct | 394 ms | 48488 KB | Output is correct |
54 | Correct | 452 ms | 56572 KB | Output is correct |
55 | Correct | 392 ms | 48764 KB | Output is correct |