Submission #431511

# Submission time Handle Problem Language Result Execution time Memory
431511 2021-06-17T12:32:35 Z errorgorn Long Mansion (JOI17_long_mansion) C++17
10 / 100
221 ms 2792 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,q;
int arr[5005];
vector<int> keys[5005];

bool has[5005];

int l[5005],r[5005];

int main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n;
	rep(x,2,n+1) cin>>arr[x];
	
	int a,b;
	rep(x,1,n+1){
		cin>>a;
		rep(y,0,a){
			cin>>b;
			keys[x].pub(b);
		}
	}
	
	rep(x,1,n+1){
		swap(arr[x-1],arr[x]);
		
		memset(has,false,sizeof(has));
		for (auto &it:keys[x]) has[it]=true;
		
		int left=x,right=x;
		while (true){
			if (left!=1 && has[arr[left-1]]){
				left--;
				for (auto &it:keys[left]) has[it]=true;
			}
			else if (right!=n && has[arr[right+1]]){
				right++;
				for (auto &it:keys[right]) has[it]=true;
			}
			else break;
		}
		
		//cout<<left<<" "<<right<<endl;
		tie(l[x],r[x])=ii(left,right);
	}
	
	cin>>q;
	
	while (q--){
		cin>>a>>b;
		
		if (b<l[a] || r[a]<b) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 588 KB Output is correct
2 Correct 30 ms 624 KB Output is correct
3 Correct 73 ms 684 KB Output is correct
4 Correct 4 ms 588 KB Output is correct
5 Correct 35 ms 580 KB Output is correct
6 Correct 9 ms 588 KB Output is correct
7 Correct 8 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 588 KB Output is correct
2 Correct 30 ms 624 KB Output is correct
3 Correct 73 ms 684 KB Output is correct
4 Correct 4 ms 588 KB Output is correct
5 Correct 35 ms 580 KB Output is correct
6 Correct 9 ms 588 KB Output is correct
7 Correct 8 ms 612 KB Output is correct
8 Correct 155 ms 2252 KB Output is correct
9 Correct 147 ms 2280 KB Output is correct
10 Correct 166 ms 2444 KB Output is correct
11 Correct 221 ms 2648 KB Output is correct
12 Correct 139 ms 2456 KB Output is correct
13 Correct 163 ms 2492 KB Output is correct
14 Correct 138 ms 2536 KB Output is correct
15 Correct 145 ms 2560 KB Output is correct
16 Correct 164 ms 2784 KB Output is correct
17 Correct 150 ms 2448 KB Output is correct
18 Correct 155 ms 2568 KB Output is correct
19 Correct 145 ms 2568 KB Output is correct
20 Correct 156 ms 2612 KB Output is correct
21 Correct 165 ms 2792 KB Output is correct
22 Correct 157 ms 2460 KB Output is correct
23 Correct 148 ms 2392 KB Output is correct
24 Correct 160 ms 2348 KB Output is correct
25 Correct 155 ms 2324 KB Output is correct
26 Correct 142 ms 2292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 864 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 588 KB Output is correct
2 Correct 30 ms 624 KB Output is correct
3 Correct 73 ms 684 KB Output is correct
4 Correct 4 ms 588 KB Output is correct
5 Correct 35 ms 580 KB Output is correct
6 Correct 9 ms 588 KB Output is correct
7 Correct 8 ms 612 KB Output is correct
8 Correct 155 ms 2252 KB Output is correct
9 Correct 147 ms 2280 KB Output is correct
10 Correct 166 ms 2444 KB Output is correct
11 Correct 221 ms 2648 KB Output is correct
12 Correct 139 ms 2456 KB Output is correct
13 Correct 163 ms 2492 KB Output is correct
14 Correct 138 ms 2536 KB Output is correct
15 Correct 145 ms 2560 KB Output is correct
16 Correct 164 ms 2784 KB Output is correct
17 Correct 150 ms 2448 KB Output is correct
18 Correct 155 ms 2568 KB Output is correct
19 Correct 145 ms 2568 KB Output is correct
20 Correct 156 ms 2612 KB Output is correct
21 Correct 165 ms 2792 KB Output is correct
22 Correct 157 ms 2460 KB Output is correct
23 Correct 148 ms 2392 KB Output is correct
24 Correct 160 ms 2348 KB Output is correct
25 Correct 155 ms 2324 KB Output is correct
26 Correct 142 ms 2292 KB Output is correct
27 Runtime error 2 ms 864 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -