# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
282433 | 2020-08-24T12:24:55 Z | MKopchev | Long Mansion (JOI17_long_mansion) | C++14 | 3000 ms | 9208 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=1e5+42; int n,inp[nmax]; vector<int> seen[nmax]; int can_l[nmax],can_r[nmax]; bool test(int val,int l,int r) { if(seen[val].size()==0)return 0; int p=lower_bound(seen[val].begin(),seen[val].end(),l)-seen[val].begin(); if(p<seen[val].size()&&seen[val][p]<=r)return 1; return 0; } int main() { scanf("%i",&n); for(int i=1;i<n;i++)scanf("%i",&inp[i]); for(int i=1;i<=n;i++) { int sz,val; scanf("%i",&sz); for(int j=1;j<=sz;j++) { scanf("%i",&val); seen[val].push_back(i); } } for(int i=1;i<=n;i++) { can_l[i]=i; can_r[i]=i; while(can_l[i]!=1||can_r[i]!=n) { if(can_l[i]!=1&&test(inp[can_l[i]-1],can_l[i],can_r[i]))can_l[i]--; else if(can_r[i]!=n&&test(inp[can_r[i]],can_l[i],can_r[i]))can_r[i]++; else break; } } int q; scanf("%i",&q); for(int i=1;i<=q;i++) { int le,ri; scanf("%i%i",&le,&ri); if(can_l[le]<=ri&&ri<=can_r[le])printf("YES\n"); else printf("NO\n"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 2816 KB | Output is correct |
2 | Correct | 100 ms | 2868 KB | Output is correct |
3 | Correct | 508 ms | 2936 KB | Output is correct |
4 | Correct | 6 ms | 2816 KB | Output is correct |
5 | Correct | 94 ms | 2836 KB | Output is correct |
6 | Correct | 16 ms | 2816 KB | Output is correct |
7 | Correct | 13 ms | 2816 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 2816 KB | Output is correct |
2 | Correct | 100 ms | 2868 KB | Output is correct |
3 | Correct | 508 ms | 2936 KB | Output is correct |
4 | Correct | 6 ms | 2816 KB | Output is correct |
5 | Correct | 94 ms | 2836 KB | Output is correct |
6 | Correct | 16 ms | 2816 KB | Output is correct |
7 | Correct | 13 ms | 2816 KB | Output is correct |
8 | Correct | 185 ms | 8696 KB | Output is correct |
9 | Correct | 160 ms | 8568 KB | Output is correct |
10 | Correct | 254 ms | 8952 KB | Output is correct |
11 | Correct | 683 ms | 9208 KB | Output is correct |
12 | Correct | 170 ms | 8264 KB | Output is correct |
13 | Correct | 154 ms | 8824 KB | Output is correct |
14 | Correct | 144 ms | 8860 KB | Output is correct |
15 | Correct | 182 ms | 8824 KB | Output is correct |
16 | Correct | 221 ms | 8696 KB | Output is correct |
17 | Correct | 144 ms | 8956 KB | Output is correct |
18 | Correct | 143 ms | 8824 KB | Output is correct |
19 | Correct | 147 ms | 8824 KB | Output is correct |
20 | Correct | 207 ms | 8844 KB | Output is correct |
21 | Correct | 261 ms | 8696 KB | Output is correct |
22 | Correct | 167 ms | 8700 KB | Output is correct |
23 | Correct | 160 ms | 8568 KB | Output is correct |
24 | Correct | 161 ms | 8568 KB | Output is correct |
25 | Correct | 157 ms | 8696 KB | Output is correct |
26 | Correct | 177 ms | 8696 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3062 ms | 7932 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 2816 KB | Output is correct |
2 | Correct | 100 ms | 2868 KB | Output is correct |
3 | Correct | 508 ms | 2936 KB | Output is correct |
4 | Correct | 6 ms | 2816 KB | Output is correct |
5 | Correct | 94 ms | 2836 KB | Output is correct |
6 | Correct | 16 ms | 2816 KB | Output is correct |
7 | Correct | 13 ms | 2816 KB | Output is correct |
8 | Correct | 185 ms | 8696 KB | Output is correct |
9 | Correct | 160 ms | 8568 KB | Output is correct |
10 | Correct | 254 ms | 8952 KB | Output is correct |
11 | Correct | 683 ms | 9208 KB | Output is correct |
12 | Correct | 170 ms | 8264 KB | Output is correct |
13 | Correct | 154 ms | 8824 KB | Output is correct |
14 | Correct | 144 ms | 8860 KB | Output is correct |
15 | Correct | 182 ms | 8824 KB | Output is correct |
16 | Correct | 221 ms | 8696 KB | Output is correct |
17 | Correct | 144 ms | 8956 KB | Output is correct |
18 | Correct | 143 ms | 8824 KB | Output is correct |
19 | Correct | 147 ms | 8824 KB | Output is correct |
20 | Correct | 207 ms | 8844 KB | Output is correct |
21 | Correct | 261 ms | 8696 KB | Output is correct |
22 | Correct | 167 ms | 8700 KB | Output is correct |
23 | Correct | 160 ms | 8568 KB | Output is correct |
24 | Correct | 161 ms | 8568 KB | Output is correct |
25 | Correct | 157 ms | 8696 KB | Output is correct |
26 | Correct | 177 ms | 8696 KB | Output is correct |
27 | Execution timed out | 3062 ms | 7932 KB | Time limit exceeded |
28 | Halted | 0 ms | 0 KB | - |