# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260483 | 2020-08-10T11:12:26 Z | fadi57 | Long Mansion (JOI17_long_mansion) | C++14 | 1898 ms | 7420 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int mx=500000; ll c[mx]; ll b[mx]; vector<ll>keys[10000]; 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(int j=0;j<b[i];j++){ int x; cin>>x; keys[i].push_back(x); } }//cout<<keys[4][0]<<endl; for(int i=n;i>=1;i--){ map<ll,ll>ok; for(int 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(int 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 768 KB | Output is correct |
2 | Correct | 138 ms | 760 KB | Output is correct |
3 | Correct | 307 ms | 1016 KB | Output is correct |
4 | Correct | 42 ms | 768 KB | Output is correct |
5 | Correct | 454 ms | 768 KB | Output is correct |
6 | Correct | 200 ms | 1028 KB | Output is correct |
7 | Correct | 140 ms | 912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 768 KB | Output is correct |
2 | Correct | 138 ms | 760 KB | Output is correct |
3 | Correct | 307 ms | 1016 KB | Output is correct |
4 | Correct | 42 ms | 768 KB | Output is correct |
5 | Correct | 454 ms | 768 KB | Output is correct |
6 | Correct | 200 ms | 1028 KB | Output is correct |
7 | Correct | 140 ms | 912 KB | Output is correct |
8 | Correct | 1486 ms | 6648 KB | Output is correct |
9 | Correct | 1483 ms | 6728 KB | Output is correct |
10 | Correct | 1591 ms | 7036 KB | Output is correct |
11 | Correct | 1755 ms | 7420 KB | Output is correct |
12 | Correct | 1474 ms | 6396 KB | Output is correct |
13 | Correct | 1455 ms | 6912 KB | Output is correct |
14 | Correct | 1477 ms | 6904 KB | Output is correct |
15 | Correct | 1704 ms | 6944 KB | Output is correct |
16 | Correct | 1857 ms | 6652 KB | Output is correct |
17 | Correct | 1456 ms | 7008 KB | Output is correct |
18 | Correct | 1501 ms | 7032 KB | Output is correct |
19 | Correct | 1602 ms | 6908 KB | Output is correct |
20 | Correct | 1893 ms | 6776 KB | Output is correct |
21 | Correct | 1898 ms | 6756 KB | Output is correct |
22 | Correct | 1859 ms | 6776 KB | Output is correct |
23 | Correct | 1632 ms | 6648 KB | Output is correct |
24 | Correct | 1593 ms | 6748 KB | Output is correct |
25 | Correct | 1574 ms | 6756 KB | Output is correct |
26 | Correct | 1521 ms | 6724 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 46 ms | 4516 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 768 KB | Output is correct |
2 | Correct | 138 ms | 760 KB | Output is correct |
3 | Correct | 307 ms | 1016 KB | Output is correct |
4 | Correct | 42 ms | 768 KB | Output is correct |
5 | Correct | 454 ms | 768 KB | Output is correct |
6 | Correct | 200 ms | 1028 KB | Output is correct |
7 | Correct | 140 ms | 912 KB | Output is correct |
8 | Correct | 1486 ms | 6648 KB | Output is correct |
9 | Correct | 1483 ms | 6728 KB | Output is correct |
10 | Correct | 1591 ms | 7036 KB | Output is correct |
11 | Correct | 1755 ms | 7420 KB | Output is correct |
12 | Correct | 1474 ms | 6396 KB | Output is correct |
13 | Correct | 1455 ms | 6912 KB | Output is correct |
14 | Correct | 1477 ms | 6904 KB | Output is correct |
15 | Correct | 1704 ms | 6944 KB | Output is correct |
16 | Correct | 1857 ms | 6652 KB | Output is correct |
17 | Correct | 1456 ms | 7008 KB | Output is correct |
18 | Correct | 1501 ms | 7032 KB | Output is correct |
19 | Correct | 1602 ms | 6908 KB | Output is correct |
20 | Correct | 1893 ms | 6776 KB | Output is correct |
21 | Correct | 1898 ms | 6756 KB | Output is correct |
22 | Correct | 1859 ms | 6776 KB | Output is correct |
23 | Correct | 1632 ms | 6648 KB | Output is correct |
24 | Correct | 1593 ms | 6748 KB | Output is correct |
25 | Correct | 1574 ms | 6756 KB | Output is correct |
26 | Correct | 1521 ms | 6724 KB | Output is correct |
27 | Runtime error | 46 ms | 4516 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
28 | Halted | 0 ms | 0 KB | - |