# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
60393 | 2018-07-24T05:14:07 Z | 정원준(#1745) | Long Mansion (JOI17_long_mansion) | C++11 | 3000 ms | 19348 KB |
#include <bits/stdc++.h> #define L long long using namespace std; L n,q; L cor[100010]; L lef[100010],rig[100010]; L sz[100010]; vector<L>v[100010]; L chk[100010],chkcolor; int main() { scanf("%lld",&n); L i,j; for(i=1;i<n;i++) { scanf("%lld",&cor[i]); } for(i=1;i<=n;i++) { scanf("%lld",&sz[i]); for(j=1;j<=sz[i];j++) { L sctemp; scanf("%lld ",&sctemp); v[i].push_back(sctemp); } } for(i=1;i<=n;i++) { chkcolor++; lef[i]=rig[i]=i; for(j=0;j<v[i].size();j++) { chk[v[i][j]]=chkcolor; } while(1) { if(lef[i]>1&&chk[cor[lef[i]-1]]==chkcolor) { lef[i]--; for(j=0;j<v[lef[i]].size();j++) { chk[v[lef[i]][j]]=chkcolor; } } else if(rig[i]<n&&chk[cor[rig[i]]]==chkcolor) { rig[i]++; for(j=0;j<v[rig[i]].size();j++) { chk[v[rig[i]][j]]=chkcolor; } } else break; } } /*for(i=1;i<=n;i++) { printf("%lld %lld\n",lef[i],rig[i]); }*/ scanf("%lld",&q); for(i=1;i<=q;i++) { L st,ed; scanf("%lld %lld",&st,&ed); puts(lef[st]<=ed&&ed<=rig[st]?"YES":"NO"); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 2844 KB | Output is correct |
2 | Correct | 28 ms | 3108 KB | Output is correct |
3 | Correct | 58 ms | 3400 KB | Output is correct |
4 | Correct | 12 ms | 3400 KB | Output is correct |
5 | Correct | 32 ms | 3512 KB | Output is correct |
6 | Correct | 12 ms | 3512 KB | Output is correct |
7 | Correct | 18 ms | 3620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 2844 KB | Output is correct |
2 | Correct | 28 ms | 3108 KB | Output is correct |
3 | Correct | 58 ms | 3400 KB | Output is correct |
4 | Correct | 12 ms | 3400 KB | Output is correct |
5 | Correct | 32 ms | 3512 KB | Output is correct |
6 | Correct | 12 ms | 3512 KB | Output is correct |
7 | Correct | 18 ms | 3620 KB | Output is correct |
8 | Correct | 186 ms | 8516 KB | Output is correct |
9 | Correct | 200 ms | 9976 KB | Output is correct |
10 | Correct | 210 ms | 13204 KB | Output is correct |
11 | Correct | 289 ms | 13328 KB | Output is correct |
12 | Correct | 156 ms | 13328 KB | Output is correct |
13 | Correct | 141 ms | 13328 KB | Output is correct |
14 | Correct | 194 ms | 13328 KB | Output is correct |
15 | Correct | 160 ms | 13328 KB | Output is correct |
16 | Correct | 171 ms | 13436 KB | Output is correct |
17 | Correct | 155 ms | 13436 KB | Output is correct |
18 | Correct | 207 ms | 13436 KB | Output is correct |
19 | Correct | 152 ms | 13436 KB | Output is correct |
20 | Correct | 203 ms | 13436 KB | Output is correct |
21 | Correct | 145 ms | 13436 KB | Output is correct |
22 | Correct | 238 ms | 13436 KB | Output is correct |
23 | Correct | 143 ms | 13436 KB | Output is correct |
24 | Correct | 139 ms | 13436 KB | Output is correct |
25 | Correct | 150 ms | 13436 KB | Output is correct |
26 | Correct | 152 ms | 13436 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3027 ms | 19348 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 2844 KB | Output is correct |
2 | Correct | 28 ms | 3108 KB | Output is correct |
3 | Correct | 58 ms | 3400 KB | Output is correct |
4 | Correct | 12 ms | 3400 KB | Output is correct |
5 | Correct | 32 ms | 3512 KB | Output is correct |
6 | Correct | 12 ms | 3512 KB | Output is correct |
7 | Correct | 18 ms | 3620 KB | Output is correct |
8 | Correct | 186 ms | 8516 KB | Output is correct |
9 | Correct | 200 ms | 9976 KB | Output is correct |
10 | Correct | 210 ms | 13204 KB | Output is correct |
11 | Correct | 289 ms | 13328 KB | Output is correct |
12 | Correct | 156 ms | 13328 KB | Output is correct |
13 | Correct | 141 ms | 13328 KB | Output is correct |
14 | Correct | 194 ms | 13328 KB | Output is correct |
15 | Correct | 160 ms | 13328 KB | Output is correct |
16 | Correct | 171 ms | 13436 KB | Output is correct |
17 | Correct | 155 ms | 13436 KB | Output is correct |
18 | Correct | 207 ms | 13436 KB | Output is correct |
19 | Correct | 152 ms | 13436 KB | Output is correct |
20 | Correct | 203 ms | 13436 KB | Output is correct |
21 | Correct | 145 ms | 13436 KB | Output is correct |
22 | Correct | 238 ms | 13436 KB | Output is correct |
23 | Correct | 143 ms | 13436 KB | Output is correct |
24 | Correct | 139 ms | 13436 KB | Output is correct |
25 | Correct | 150 ms | 13436 KB | Output is correct |
26 | Correct | 152 ms | 13436 KB | Output is correct |
27 | Execution timed out | 3027 ms | 19348 KB | Time limit exceeded |
28 | Halted | 0 ms | 0 KB | - |