# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260487 | 2020-08-10T11:15:42 Z | fadi57 | Long Mansion (JOI17_long_mansion) | C++14 | 3000 ms | 21028 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int mx=500020; ll c[mx]; ll b[mx]; vector<ll>keys[mx]; ll mxright[mx]; ll mxleft[mx]; int main() { ll n,m;cin>>n; for(ll i=1;i<n;i++){ cin>>c[i]; } for(ll i=1;i<=n;i++){ cin>>b[i]; for(ll j=0;j<b[i];j++){ ll x; cin>>x; keys[i].push_back(x); } }//cout<<keys[4][0]<<endl; for(ll i=n;i>=1;i--){ map<ll,ll>ok; for(ll j=0;j<b[i];j++){ ok[keys[i][j]]=1;//cout<<keys[i][j]<<"ji"<<endl; }ll myr=i; ll myl=i; while(1){ ll xx=0;ll xo=0; if(myr<n&&ok[c[myr]]){ xx=1; myr++; //here we add the new keys for(int j=0;j<b[myr];j++){ ok[keys[myr][j]]=1; } } if(myl>1&&ok[c[myl-1]]){ xo=1; myl--; for(int j=0;j<b[myl];j++){ ok[keys[myl][j]]=1; } } if(xo||xx){ }else{ break; } } mxleft[i]=myl;mxright[i]=myr; // cout<<myl<<" "<<myr<<endl; //return 0; }//cout<<mxright[1]; ll q;cin>>q; for(ll i=0;i<q;i++){ ll x,y;cin>>x>>y; //cout<<mxleft[x]<<" "<<mxright[x]; if(mxleft[x]<=y&&y<=mxright[x]){ cout<<"YES"; }else{cout<<"NO";} cout<<endl; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 12280 KB | Output is correct |
2 | Correct | 141 ms | 12428 KB | Output is correct |
3 | Correct | 297 ms | 12408 KB | Output is correct |
4 | Correct | 47 ms | 12280 KB | Output is correct |
5 | Correct | 461 ms | 12368 KB | Output is correct |
6 | Correct | 200 ms | 12280 KB | Output is correct |
7 | Correct | 147 ms | 12288 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 12280 KB | Output is correct |
2 | Correct | 141 ms | 12428 KB | Output is correct |
3 | Correct | 297 ms | 12408 KB | Output is correct |
4 | Correct | 47 ms | 12280 KB | Output is correct |
5 | Correct | 461 ms | 12368 KB | Output is correct |
6 | Correct | 200 ms | 12280 KB | Output is correct |
7 | Correct | 147 ms | 12288 KB | Output is correct |
8 | Correct | 1567 ms | 13724 KB | Output is correct |
9 | Correct | 1488 ms | 13732 KB | Output is correct |
10 | Correct | 1594 ms | 13944 KB | Output is correct |
11 | Correct | 1779 ms | 14304 KB | Output is correct |
12 | Correct | 1507 ms | 14048 KB | Output is correct |
13 | Correct | 1477 ms | 14048 KB | Output is correct |
14 | Correct | 1509 ms | 13944 KB | Output is correct |
15 | Correct | 1685 ms | 14080 KB | Output is correct |
16 | Correct | 1874 ms | 14164 KB | Output is correct |
17 | Correct | 1511 ms | 14028 KB | Output is correct |
18 | Correct | 1480 ms | 13944 KB | Output is correct |
19 | Correct | 1548 ms | 13944 KB | Output is correct |
20 | Correct | 1896 ms | 14072 KB | Output is correct |
21 | Correct | 1864 ms | 14200 KB | Output is correct |
22 | Correct | 1855 ms | 14072 KB | Output is correct |
23 | Correct | 1651 ms | 13944 KB | Output is correct |
24 | Correct | 1620 ms | 14084 KB | Output is correct |
25 | Correct | 1584 ms | 13944 KB | Output is correct |
26 | Correct | 1518 ms | 13816 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3096 ms | 21028 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 12280 KB | Output is correct |
2 | Correct | 141 ms | 12428 KB | Output is correct |
3 | Correct | 297 ms | 12408 KB | Output is correct |
4 | Correct | 47 ms | 12280 KB | Output is correct |
5 | Correct | 461 ms | 12368 KB | Output is correct |
6 | Correct | 200 ms | 12280 KB | Output is correct |
7 | Correct | 147 ms | 12288 KB | Output is correct |
8 | Correct | 1567 ms | 13724 KB | Output is correct |
9 | Correct | 1488 ms | 13732 KB | Output is correct |
10 | Correct | 1594 ms | 13944 KB | Output is correct |
11 | Correct | 1779 ms | 14304 KB | Output is correct |
12 | Correct | 1507 ms | 14048 KB | Output is correct |
13 | Correct | 1477 ms | 14048 KB | Output is correct |
14 | Correct | 1509 ms | 13944 KB | Output is correct |
15 | Correct | 1685 ms | 14080 KB | Output is correct |
16 | Correct | 1874 ms | 14164 KB | Output is correct |
17 | Correct | 1511 ms | 14028 KB | Output is correct |
18 | Correct | 1480 ms | 13944 KB | Output is correct |
19 | Correct | 1548 ms | 13944 KB | Output is correct |
20 | Correct | 1896 ms | 14072 KB | Output is correct |
21 | Correct | 1864 ms | 14200 KB | Output is correct |
22 | Correct | 1855 ms | 14072 KB | Output is correct |
23 | Correct | 1651 ms | 13944 KB | Output is correct |
24 | Correct | 1620 ms | 14084 KB | Output is correct |
25 | Correct | 1584 ms | 13944 KB | Output is correct |
26 | Correct | 1518 ms | 13816 KB | Output is correct |
27 | Execution timed out | 3096 ms | 21028 KB | Time limit exceeded |
28 | Halted | 0 ms | 0 KB | - |