# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
296263 | 2020-09-10T12:52:25 Z | BThero | Long Mansion (JOI17_long_mansion) | C++17 | 3000 ms | 8944 KB |
// chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MAXN = (int)5e3 + 5; vector<int> keys[MAXN]; int betw[MAXN]; int A[MAXN], B[MAXN]; int n, q; void solve() { scanf("%d", &n); for (int i = 1; i < n; ++i) { scanf("%d", &betw[i]); } for (int i = 1; i <= n; ++i) { int sz; scanf("%d", &sz); keys[i].resize(sz); for (int j = 0; j < sz; ++j) { scanf("%d", &keys[i][j]); } } for (int i = 1; i < n; ++i) { int p = i + 1; while (p <= n && find(all(keys[p]), betw[i]) == keys[p].end()) { ++p; } B[i] = p; } for (int i = 2; i <= n; ++i) { int p = i - 1; while (p > 0 && find(all(keys[p]), betw[i - 1]) == keys[p].end()) { --p; } A[i] = p; } B[0] = n + 1; A[n + 1] = 0; vector<pii> bad; for (int l = 1; l <= n; ++l) { for (int r = l; r <= n; ++r) { if (B[l - 1] > r && A[r + 1] < l) { bad.eb(l, r); } } } scanf("%d", &q); for (int i = 1; i <= q; ++i) { int a, b; scanf("%d %d", &a, &b); // a -> b bool ans = 1; if (a < b) { for (auto it : bad) { if (it.fi <= a && it.se >= a && it.se < b) { ans = 0; break; } } } else { for (auto it : bad) { if (b < it.fi && it.fi <= a && it.se >= a) { ans = 0; break; } } } if (ans) { printf("YES\n"); } else { printf("NO\n"); } } } int main() { int tt = 1; while (tt--) { solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 640 KB | Output is correct |
2 | Correct | 26 ms | 640 KB | Output is correct |
3 | Correct | 82 ms | 760 KB | Output is correct |
4 | Correct | 22 ms | 640 KB | Output is correct |
5 | Correct | 9 ms | 544 KB | Output is correct |
6 | Correct | 12 ms | 640 KB | Output is correct |
7 | Correct | 1794 ms | 8944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 640 KB | Output is correct |
2 | Correct | 26 ms | 640 KB | Output is correct |
3 | Correct | 82 ms | 760 KB | Output is correct |
4 | Correct | 22 ms | 640 KB | Output is correct |
5 | Correct | 9 ms | 544 KB | Output is correct |
6 | Correct | 12 ms | 640 KB | Output is correct |
7 | Correct | 1794 ms | 8944 KB | Output is correct |
8 | Correct | 1132 ms | 2292 KB | Output is correct |
9 | Correct | 1511 ms | 2156 KB | Output is correct |
10 | Correct | 1096 ms | 2312 KB | Output is correct |
11 | Correct | 1216 ms | 2552 KB | Output is correct |
12 | Correct | 380 ms | 2284 KB | Output is correct |
13 | Correct | 1254 ms | 2388 KB | Output is correct |
14 | Correct | 857 ms | 2336 KB | Output is correct |
15 | Correct | 208 ms | 2296 KB | Output is correct |
16 | Correct | 184 ms | 2588 KB | Output is correct |
17 | Correct | 602 ms | 2472 KB | Output is correct |
18 | Correct | 372 ms | 2296 KB | Output is correct |
19 | Correct | 271 ms | 2296 KB | Output is correct |
20 | Correct | 183 ms | 2424 KB | Output is correct |
21 | Correct | 161 ms | 2552 KB | Output is correct |
22 | Correct | 172 ms | 2296 KB | Output is correct |
23 | Execution timed out | 3100 ms | 8936 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5 ms | 384 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 640 KB | Output is correct |
2 | Correct | 26 ms | 640 KB | Output is correct |
3 | Correct | 82 ms | 760 KB | Output is correct |
4 | Correct | 22 ms | 640 KB | Output is correct |
5 | Correct | 9 ms | 544 KB | Output is correct |
6 | Correct | 12 ms | 640 KB | Output is correct |
7 | Correct | 1794 ms | 8944 KB | Output is correct |
8 | Correct | 1132 ms | 2292 KB | Output is correct |
9 | Correct | 1511 ms | 2156 KB | Output is correct |
10 | Correct | 1096 ms | 2312 KB | Output is correct |
11 | Correct | 1216 ms | 2552 KB | Output is correct |
12 | Correct | 380 ms | 2284 KB | Output is correct |
13 | Correct | 1254 ms | 2388 KB | Output is correct |
14 | Correct | 857 ms | 2336 KB | Output is correct |
15 | Correct | 208 ms | 2296 KB | Output is correct |
16 | Correct | 184 ms | 2588 KB | Output is correct |
17 | Correct | 602 ms | 2472 KB | Output is correct |
18 | Correct | 372 ms | 2296 KB | Output is correct |
19 | Correct | 271 ms | 2296 KB | Output is correct |
20 | Correct | 183 ms | 2424 KB | Output is correct |
21 | Correct | 161 ms | 2552 KB | Output is correct |
22 | Correct | 172 ms | 2296 KB | Output is correct |
23 | Execution timed out | 3100 ms | 8936 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |