# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
296254 | 2020-09-10T12:41:21 Z | BThero | Long Mansion (JOI17_long_mansion) | C++17 | 466 ms | 14072 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<pii> bad[MAXN]; vector<int> keys[MAXN]; pii seg[MAXN]; int betw[MAXN]; int A[MAXN], B[MAXN]; int n, q; int own[MAXN]; 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; for (int l = 1; l <= n; ++l) { for (int r = l; r <= n; ++r) { if (B[l - 1] > r && A[r + 1] < l) { bad[r - l + 1].eb(l, r); } } } for (int i = 1; i <= n; ++i) { seg[i] = mp(-1, -1); } for (int len = 1; len <= n; ++len) { vector<pii> mark(n + 5, mp(-1, -1)); for (auto it : bad[len]) { for (int i = it.fi; i <= it.se; ++i) { if (mark[i] != mp(-1, -1)) { assert(seg[i] != mp(-1, -1)); } mark[i] = it; } } for (int i = 1; i <= n; ++i) { if (seg[i] == mp(-1, -1)) { seg[i] = mark[i]; } } } scanf("%d", &q); for (int i = 1; i <= q; ++i) { int a, b; scanf("%d %d", &a, &b); if (seg[a].fi <= b && b <= seg[a].se) { printf("YES\n"); } else { printf("NO\n"); } } } int main() { int tt = 1; while (tt--) { solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 896 KB | Output is correct |
2 | Correct | 55 ms | 1016 KB | Output is correct |
3 | Correct | 145 ms | 1144 KB | Output is correct |
4 | Correct | 20 ms | 768 KB | Output is correct |
5 | Correct | 20 ms | 804 KB | Output is correct |
6 | Correct | 19 ms | 768 KB | Output is correct |
7 | Correct | 229 ms | 8184 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 896 KB | Output is correct |
2 | Correct | 55 ms | 1016 KB | Output is correct |
3 | Correct | 145 ms | 1144 KB | Output is correct |
4 | Correct | 20 ms | 768 KB | Output is correct |
5 | Correct | 20 ms | 804 KB | Output is correct |
6 | Correct | 19 ms | 768 KB | Output is correct |
7 | Correct | 229 ms | 8184 KB | Output is correct |
8 | Correct | 180 ms | 5552 KB | Output is correct |
9 | Correct | 190 ms | 5496 KB | Output is correct |
10 | Correct | 211 ms | 5628 KB | Output is correct |
11 | Correct | 311 ms | 5880 KB | Output is correct |
12 | Correct | 162 ms | 5624 KB | Output is correct |
13 | Correct | 180 ms | 5624 KB | Output is correct |
14 | Correct | 176 ms | 5604 KB | Output is correct |
15 | Correct | 174 ms | 5752 KB | Output is correct |
16 | Correct | 171 ms | 6008 KB | Output is correct |
17 | Correct | 173 ms | 5624 KB | Output is correct |
18 | Correct | 176 ms | 5624 KB | Output is correct |
19 | Correct | 174 ms | 5624 KB | Output is correct |
20 | Correct | 167 ms | 5732 KB | Output is correct |
21 | Correct | 167 ms | 5880 KB | Output is correct |
22 | Correct | 174 ms | 5624 KB | Output is correct |
23 | Correct | 387 ms | 12832 KB | Output is correct |
24 | Correct | 406 ms | 12920 KB | Output is correct |
25 | Correct | 385 ms | 12852 KB | Output is correct |
26 | Correct | 466 ms | 14072 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 10 ms | 1024 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 896 KB | Output is correct |
2 | Correct | 55 ms | 1016 KB | Output is correct |
3 | Correct | 145 ms | 1144 KB | Output is correct |
4 | Correct | 20 ms | 768 KB | Output is correct |
5 | Correct | 20 ms | 804 KB | Output is correct |
6 | Correct | 19 ms | 768 KB | Output is correct |
7 | Correct | 229 ms | 8184 KB | Output is correct |
8 | Correct | 180 ms | 5552 KB | Output is correct |
9 | Correct | 190 ms | 5496 KB | Output is correct |
10 | Correct | 211 ms | 5628 KB | Output is correct |
11 | Correct | 311 ms | 5880 KB | Output is correct |
12 | Correct | 162 ms | 5624 KB | Output is correct |
13 | Correct | 180 ms | 5624 KB | Output is correct |
14 | Correct | 176 ms | 5604 KB | Output is correct |
15 | Correct | 174 ms | 5752 KB | Output is correct |
16 | Correct | 171 ms | 6008 KB | Output is correct |
17 | Correct | 173 ms | 5624 KB | Output is correct |
18 | Correct | 176 ms | 5624 KB | Output is correct |
19 | Correct | 174 ms | 5624 KB | Output is correct |
20 | Correct | 167 ms | 5732 KB | Output is correct |
21 | Correct | 167 ms | 5880 KB | Output is correct |
22 | Correct | 174 ms | 5624 KB | Output is correct |
23 | Correct | 387 ms | 12832 KB | Output is correct |
24 | Correct | 406 ms | 12920 KB | Output is correct |
25 | Correct | 385 ms | 12852 KB | Output is correct |
26 | Correct | 466 ms | 14072 KB | Output is correct |
27 | Execution timed out | 10 ms | 1024 KB | Time limit exceeded (wall clock) |
28 | Halted | 0 ms | 0 KB | - |