# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70683 | 2018-08-23T08:29:17 Z | Just_Solve_The_Problem | Long Mansion (JOI17_long_mansion) | C++11 | 3000 ms | 89992 KB |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 7; int n; int c[N]; vector < int > keys[N]; pair < int, int > lr[N]; int has[N]; main() { scanf("%d", &n); for (int i = 1; i < n; i++) { scanf("%d", &c[i]); } for (int i = 1; i <= n; i++) { int siz; scanf("%d", &siz); for (int j = 0; j < siz; j++) { int x; scanf("%d", &x); keys[i].push_back(x); } lr[i] = {i, i}; } for (int i = 1; i <= n; i++) { int ok = 1; for (int to : keys[i]) { has[to] = i; } while (ok) { ok = 0; while (has[c[lr[i].second]] == i) { lr[i].second++; for (int to : keys[lr[i].second]) { has[to] = i; } ok = 1; } while (has[c[lr[i].first - 1]] == i) { lr[i].first--; for (int to : keys[lr[i].first]) { has[to] = i; } ok = 1; } } } // for (int i = 1; i <= n; i++) { // printf("%d %d\n", lr[i].first, lr[i].second); // } int q; scanf("%d", &q); while (q--) { int l, r; scanf("%d %d", &l, &r); if (lr[l].first <= r && r <= lr[l].second) { puts("YES"); } else { puts("NO"); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 2680 KB | Output is correct |
2 | Correct | 20 ms | 2916 KB | Output is correct |
3 | Correct | 48 ms | 3292 KB | Output is correct |
4 | Correct | 8 ms | 3360 KB | Output is correct |
5 | Correct | 24 ms | 3468 KB | Output is correct |
6 | Correct | 11 ms | 3492 KB | Output is correct |
7 | Correct | 14 ms | 3744 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 2680 KB | Output is correct |
2 | Correct | 20 ms | 2916 KB | Output is correct |
3 | Correct | 48 ms | 3292 KB | Output is correct |
4 | Correct | 8 ms | 3360 KB | Output is correct |
5 | Correct | 24 ms | 3468 KB | Output is correct |
6 | Correct | 11 ms | 3492 KB | Output is correct |
7 | Correct | 14 ms | 3744 KB | Output is correct |
8 | Correct | 173 ms | 9472 KB | Output is correct |
9 | Correct | 163 ms | 13820 KB | Output is correct |
10 | Correct | 197 ms | 18672 KB | Output is correct |
11 | Correct | 223 ms | 23516 KB | Output is correct |
12 | Correct | 153 ms | 27084 KB | Output is correct |
13 | Correct | 155 ms | 31600 KB | Output is correct |
14 | Correct | 169 ms | 36076 KB | Output is correct |
15 | Correct | 169 ms | 40284 KB | Output is correct |
16 | Correct | 188 ms | 44396 KB | Output is correct |
17 | Correct | 148 ms | 48588 KB | Output is correct |
18 | Correct | 197 ms | 52920 KB | Output is correct |
19 | Correct | 176 ms | 57380 KB | Output is correct |
20 | Correct | 150 ms | 61656 KB | Output is correct |
21 | Correct | 207 ms | 65672 KB | Output is correct |
22 | Correct | 150 ms | 69616 KB | Output is correct |
23 | Correct | 158 ms | 73744 KB | Output is correct |
24 | Correct | 146 ms | 78000 KB | Output is correct |
25 | Correct | 176 ms | 82380 KB | Output is correct |
26 | Correct | 156 ms | 86576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3005 ms | 89992 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 2680 KB | Output is correct |
2 | Correct | 20 ms | 2916 KB | Output is correct |
3 | Correct | 48 ms | 3292 KB | Output is correct |
4 | Correct | 8 ms | 3360 KB | Output is correct |
5 | Correct | 24 ms | 3468 KB | Output is correct |
6 | Correct | 11 ms | 3492 KB | Output is correct |
7 | Correct | 14 ms | 3744 KB | Output is correct |
8 | Correct | 173 ms | 9472 KB | Output is correct |
9 | Correct | 163 ms | 13820 KB | Output is correct |
10 | Correct | 197 ms | 18672 KB | Output is correct |
11 | Correct | 223 ms | 23516 KB | Output is correct |
12 | Correct | 153 ms | 27084 KB | Output is correct |
13 | Correct | 155 ms | 31600 KB | Output is correct |
14 | Correct | 169 ms | 36076 KB | Output is correct |
15 | Correct | 169 ms | 40284 KB | Output is correct |
16 | Correct | 188 ms | 44396 KB | Output is correct |
17 | Correct | 148 ms | 48588 KB | Output is correct |
18 | Correct | 197 ms | 52920 KB | Output is correct |
19 | Correct | 176 ms | 57380 KB | Output is correct |
20 | Correct | 150 ms | 61656 KB | Output is correct |
21 | Correct | 207 ms | 65672 KB | Output is correct |
22 | Correct | 150 ms | 69616 KB | Output is correct |
23 | Correct | 158 ms | 73744 KB | Output is correct |
24 | Correct | 146 ms | 78000 KB | Output is correct |
25 | Correct | 176 ms | 82380 KB | Output is correct |
26 | Correct | 156 ms | 86576 KB | Output is correct |
27 | Execution timed out | 3005 ms | 89992 KB | Time limit exceeded |
28 | Halted | 0 ms | 0 KB | - |