Submission #427808

# Submission time Handle Problem Language Result Execution time Memory
427808 2021-06-14T23:26:36 Z errorgorn Trampoline (info1cup20_trampoline) C++17
100 / 100
755 ms 53504 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 r,c,n,q;
ii arr[200005];
int nxt[200005][20];;

map<int,vector<ii> > m;

int main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>r>>c>>n;
	rep(x,0,n) cin>>arr[x].fi>>arr[x].se;
	
	sort(arr,arr+n);
	
	rep(x,0,n){
		m[arr[x].fi].pub(ii(arr[x].se,x));
	}
	
	memset(nxt,-1,sizeof(nxt));
	
	rep(x,0,n){
		int temp=-1;
		
		if (m.count(arr[x].fi+1)){
			auto iter=lb(all(m[arr[x].fi+1]),ii(arr[x].se,-1));
			if (iter!=m[arr[x].fi+1].end()) temp=(*iter).se;
		}
		
		nxt[x][0]=temp;
	}
	
	rep(x,n,0){
		int curr=nxt[x][0];
		rep(y,0,20){
			if (curr==-1) break;
			curr=nxt[x][y+1]=nxt[curr][y];
		}
	}
	
	cin>>q;
	
	int a,b,c,d;
	while (q--){
		cin>>a>>b>>c>>d;
		//cerr<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
		
		if (a>c || b>d){
			cout<<"No"<<endl;
			continue;
		}
		if (a==c){
			cout<<"Yes"<<endl;
			continue;
		}
		
		int idx=-1;
		if (m.count(a)){
			auto iter=lb(all(m[a]),ii(b,-1));
			if (iter!=m[a].end() && (*iter).fi<=d) idx=(*iter).se;
		}
		
		if (idx==-1){
			cout<<"No"<<endl;
			continue;
		}
		
		rep(x,20,0) if (nxt[idx][x]!=-1){
			if (arr[nxt[idx][x]].se<=d) idx=nxt[idx][x];
		}
		
		if (c-1<=arr[idx].fi) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 16332 KB 200 token(s): yes count is 21, no count is 179
2 Correct 12 ms 16332 KB 200 token(s): yes count is 70, no count is 130
3 Correct 11 ms 16204 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 114 ms 24200 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 113 ms 24244 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 113 ms 23064 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 115 ms 24248 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 303 ms 23856 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 292 ms 35380 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 302 ms 34784 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 387 ms 35984 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 404 ms 35996 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 561 ms 41588 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 13 ms 16204 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 14 ms 16460 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 15 ms 16868 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 14 ms 16496 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 17 ms 16588 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 14 ms 16460 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 661 ms 31236 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 543 ms 37624 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 325 ms 34972 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 755 ms 53504 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 489 ms 41540 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 335 ms 35732 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 330 ms 35740 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 312 ms 34784 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 566 ms 41596 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 681 ms 41412 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 694 ms 47056 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 277 ms 34744 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 273 ms 35568 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 410 ms 35956 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 287 ms 35668 KB 200000 token(s): yes count is 129674, no count is 70326