# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
125302 | 2019-07-05T05:06:24 Z | 이온조(#3059) | Long Mansion (JOI17_long_mansion) | C++14 | 3000 ms | 18276 KB |
#include <bits/stdc++.h> using namespace std; int L[500009], R[500009]; int C[500009], B[500009]; vector<int> A[500009]; void go(int x) { L[x] = R[x] = x; vector<bool> chk(5009, 0); for(auto& it: A[x]) chk[it] = 1; while(1) { bool f = 0; while(chk[C[L[x] - 1]]) { --L[x]; f = 1; for(auto& it: A[L[x]]) chk[it] = 1; } while(chk[C[R[x]]]) { ++R[x]; f = 1; for(auto& it: A[R[x]]) chk[it] = 1; } if(!f) break; } } int main() { int N; scanf("%d",&N); for(int i=1; i<N; i++) scanf("%d", &C[i]); for(int i=1; i<=N; i++) { scanf("%d",&B[i]); for(int j=0; j<B[i]; j++) { int foo; scanf("%d",&foo); A[i].push_back(foo); } } for(int i=1; i<=N; i++) go(i); int Q; scanf("%d",&Q); while(Q--) { int X, Y; scanf("%d%d",&X,&Y); if(L[X] <= Y && Y <= R[X]) puts("YES"); else puts("NO"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 12408 KB | Output is correct |
2 | Correct | 42 ms | 12280 KB | Output is correct |
3 | Correct | 92 ms | 12408 KB | Output is correct |
4 | Correct | 17 ms | 12280 KB | Output is correct |
5 | Correct | 59 ms | 12280 KB | Output is correct |
6 | Correct | 22 ms | 12280 KB | Output is correct |
7 | Correct | 22 ms | 12280 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 12408 KB | Output is correct |
2 | Correct | 42 ms | 12280 KB | Output is correct |
3 | Correct | 92 ms | 12408 KB | Output is correct |
4 | Correct | 17 ms | 12280 KB | Output is correct |
5 | Correct | 59 ms | 12280 KB | Output is correct |
6 | Correct | 22 ms | 12280 KB | Output is correct |
7 | Correct | 22 ms | 12280 KB | Output is correct |
8 | Correct | 144 ms | 14820 KB | Output is correct |
9 | Correct | 139 ms | 14976 KB | Output is correct |
10 | Correct | 169 ms | 14976 KB | Output is correct |
11 | Correct | 217 ms | 15284 KB | Output is correct |
12 | Correct | 145 ms | 15096 KB | Output is correct |
13 | Correct | 136 ms | 15096 KB | Output is correct |
14 | Correct | 137 ms | 15096 KB | Output is correct |
15 | Correct | 154 ms | 15228 KB | Output is correct |
16 | Correct | 174 ms | 15276 KB | Output is correct |
17 | Correct | 138 ms | 15156 KB | Output is correct |
18 | Correct | 146 ms | 15016 KB | Output is correct |
19 | Correct | 138 ms | 15100 KB | Output is correct |
20 | Correct | 167 ms | 15192 KB | Output is correct |
21 | Correct | 175 ms | 15480 KB | Output is correct |
22 | Correct | 150 ms | 15224 KB | Output is correct |
23 | Correct | 142 ms | 14968 KB | Output is correct |
24 | Correct | 142 ms | 14968 KB | Output is correct |
25 | Correct | 142 ms | 14968 KB | Output is correct |
26 | Correct | 139 ms | 14844 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3023 ms | 18276 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 12408 KB | Output is correct |
2 | Correct | 42 ms | 12280 KB | Output is correct |
3 | Correct | 92 ms | 12408 KB | Output is correct |
4 | Correct | 17 ms | 12280 KB | Output is correct |
5 | Correct | 59 ms | 12280 KB | Output is correct |
6 | Correct | 22 ms | 12280 KB | Output is correct |
7 | Correct | 22 ms | 12280 KB | Output is correct |
8 | Correct | 144 ms | 14820 KB | Output is correct |
9 | Correct | 139 ms | 14976 KB | Output is correct |
10 | Correct | 169 ms | 14976 KB | Output is correct |
11 | Correct | 217 ms | 15284 KB | Output is correct |
12 | Correct | 145 ms | 15096 KB | Output is correct |
13 | Correct | 136 ms | 15096 KB | Output is correct |
14 | Correct | 137 ms | 15096 KB | Output is correct |
15 | Correct | 154 ms | 15228 KB | Output is correct |
16 | Correct | 174 ms | 15276 KB | Output is correct |
17 | Correct | 138 ms | 15156 KB | Output is correct |
18 | Correct | 146 ms | 15016 KB | Output is correct |
19 | Correct | 138 ms | 15100 KB | Output is correct |
20 | Correct | 167 ms | 15192 KB | Output is correct |
21 | Correct | 175 ms | 15480 KB | Output is correct |
22 | Correct | 150 ms | 15224 KB | Output is correct |
23 | Correct | 142 ms | 14968 KB | Output is correct |
24 | Correct | 142 ms | 14968 KB | Output is correct |
25 | Correct | 142 ms | 14968 KB | Output is correct |
26 | Correct | 139 ms | 14844 KB | Output is correct |
27 | Execution timed out | 3023 ms | 18276 KB | Time limit exceeded |
28 | Halted | 0 ms | 0 KB | - |