# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
581834 | 2022-06-23T07:09:03 Z | 박상훈(#8364) | Long Mansion (JOI17_long_mansion) | C++17 | 3000 ms | 18792 KB |
#include <bits/stdc++.h> typedef long long ll; using namespace std; vector<int> keys[500500]; int c[500500], L[500500], R[500500], cur[500500]; int n; void calc(int s){ fill(cur, cur+n+2, 0); L[s] = s, R[s] = s; for (auto &x:keys[s]) cur[x] = 1; while(true){ int kl = L[s]>1?c[L[s]-1]:n+1; int kr = R[s]<n?c[R[s]]:n+1; if (cur[kl]){ L[s]--; for (auto &x:keys[L[s]]) cur[x] = 1; } else if (cur[kr]){ R[s]++; for (auto &x:keys[R[s]]) cur[x] = 1; } else break; } } int main(){ scanf("%d", &n); for (int i=1;i<=n-1;i++) scanf("%d", c+i); for (int i=1;i<=n;i++){ int x; scanf("%d", &x); for (int j=1;j<=x;j++){ int y; scanf("%d", &y); keys[i].push_back(y); } } for (int i=1;i<=n;i++) calc(i); int q; scanf("%d", &q); while(q--){ int x, y; scanf("%d %d", &x, &y); if (L[x] <= y && y <= R[x]) printf("YES\n"); else printf("NO\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 12244 KB | Output is correct |
2 | Correct | 31 ms | 12188 KB | Output is correct |
3 | Correct | 82 ms | 12360 KB | Output is correct |
4 | Correct | 10 ms | 12244 KB | Output is correct |
5 | Correct | 40 ms | 12124 KB | Output is correct |
6 | Correct | 18 ms | 12244 KB | Output is correct |
7 | Correct | 15 ms | 12208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 12244 KB | Output is correct |
2 | Correct | 31 ms | 12188 KB | Output is correct |
3 | Correct | 82 ms | 12360 KB | Output is correct |
4 | Correct | 10 ms | 12244 KB | Output is correct |
5 | Correct | 40 ms | 12124 KB | Output is correct |
6 | Correct | 18 ms | 12244 KB | Output is correct |
7 | Correct | 15 ms | 12208 KB | Output is correct |
8 | Correct | 133 ms | 18016 KB | Output is correct |
9 | Correct | 118 ms | 17992 KB | Output is correct |
10 | Correct | 153 ms | 18312 KB | Output is correct |
11 | Correct | 199 ms | 18792 KB | Output is correct |
12 | Correct | 121 ms | 17580 KB | Output is correct |
13 | Correct | 146 ms | 18184 KB | Output is correct |
14 | Correct | 122 ms | 18280 KB | Output is correct |
15 | Correct | 133 ms | 18252 KB | Output is correct |
16 | Correct | 143 ms | 18136 KB | Output is correct |
17 | Correct | 118 ms | 18244 KB | Output is correct |
18 | Correct | 115 ms | 18208 KB | Output is correct |
19 | Correct | 125 ms | 18272 KB | Output is correct |
20 | Correct | 152 ms | 18212 KB | Output is correct |
21 | Correct | 151 ms | 17996 KB | Output is correct |
22 | Correct | 135 ms | 18076 KB | Output is correct |
23 | Correct | 128 ms | 17976 KB | Output is correct |
24 | Correct | 126 ms | 17940 KB | Output is correct |
25 | Correct | 128 ms | 17940 KB | Output is correct |
26 | Correct | 124 ms | 17952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3089 ms | 18280 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 12244 KB | Output is correct |
2 | Correct | 31 ms | 12188 KB | Output is correct |
3 | Correct | 82 ms | 12360 KB | Output is correct |
4 | Correct | 10 ms | 12244 KB | Output is correct |
5 | Correct | 40 ms | 12124 KB | Output is correct |
6 | Correct | 18 ms | 12244 KB | Output is correct |
7 | Correct | 15 ms | 12208 KB | Output is correct |
8 | Correct | 133 ms | 18016 KB | Output is correct |
9 | Correct | 118 ms | 17992 KB | Output is correct |
10 | Correct | 153 ms | 18312 KB | Output is correct |
11 | Correct | 199 ms | 18792 KB | Output is correct |
12 | Correct | 121 ms | 17580 KB | Output is correct |
13 | Correct | 146 ms | 18184 KB | Output is correct |
14 | Correct | 122 ms | 18280 KB | Output is correct |
15 | Correct | 133 ms | 18252 KB | Output is correct |
16 | Correct | 143 ms | 18136 KB | Output is correct |
17 | Correct | 118 ms | 18244 KB | Output is correct |
18 | Correct | 115 ms | 18208 KB | Output is correct |
19 | Correct | 125 ms | 18272 KB | Output is correct |
20 | Correct | 152 ms | 18212 KB | Output is correct |
21 | Correct | 151 ms | 17996 KB | Output is correct |
22 | Correct | 135 ms | 18076 KB | Output is correct |
23 | Correct | 128 ms | 17976 KB | Output is correct |
24 | Correct | 126 ms | 17940 KB | Output is correct |
25 | Correct | 128 ms | 17940 KB | Output is correct |
26 | Correct | 124 ms | 17952 KB | Output is correct |
27 | Execution timed out | 3089 ms | 18280 KB | Time limit exceeded |
28 | Halted | 0 ms | 0 KB | - |