# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260618 | 2020-08-10T15:21:19 Z | fadi57 | Long Mansion (JOI17_long_mansion) | C++14 | 3000 ms | 23456 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int mx=500020; int c[mx]; ll b[mx]; vector<ll>keys[mx]; ll mxright[mx]; ll mxleft[mx]; int leftt[mx];int rightt[mx]; int last[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; memset(last ,-1 ,sizeof last); for(int i=1;i<n;i++){ for(int j:keys[i]){ last[j]=i; } leftt[c[i]]=last[c[i]]; } memset(last ,-1 ,sizeof last); for(int i=n-1;i>=1;i--){ for(int j:keys[i+1]){ last[j]=i+1; } rightt[c[i]]=last[c[i]]; } //current complexity n^3 for(ll i=n;i>=1;i--){ ll myr=i; ll myl=i; while(1){ ll xx=0;ll xo=0; if(myr<n&&leftt[c[myr]]>=myl){ xx=1; myr++; //here we add the new keys } if(myl>1&&rightt[c[myl-1]]<=myr&&rightt[c[myl-1]]!=-1){ xo=1; myl--; } 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 | Incorrect | 35 ms | 14336 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 35 ms | 14336 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3072 ms | 23456 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 35 ms | 14336 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |