Submission #1028704

# Submission time Handle Problem Language Result Execution time Memory
1028704 2024-07-20T07:24:09 Z vjudge1 Trampoline (info1cup20_trampoline) C++17
100 / 100
749 ms 67996 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define int long long int
#define endl '\n'
#define N 200100
#define M 30
#define big 2147483647 
#define bigg 9223372036854775807 
#define pb push_back
#define p push
#define ins insert
#define f first
#define s second

int lca[N][M];
vector<pair<int,int>> ikinci;
int gittik[N];
void dfs(int x,int a,int b){
	if(gittik[x])return ;
	gittik[x]=1;
	lca[x][0]=x;
	pair<int,int> pa={a+1,b};
	int yeni=(lower_bound(ikinci.begin(),ikinci.end(),pa)-ikinci.begin());

	if(yeni!=(int)ikinci.size()&&ikinci[yeni].f==a+1){
		lca[x][0]=yeni;
		if(gittik[yeni]==0)dfs(yeni,a+1,ikinci[yeni].s);
		return;
	}
}
void doldur(){
	for(int i=1;i<M;i++){
		for(int j=0;j<(int)ikinci.size();j++){
			lca[j][i]=lca[lca[j][i-1]][i-1];
		}
	}
}
int qua(int x,int y,int a,int b){
	a--;
	pair<int,int> pa={x,y};
	int node=lower_bound(ikinci.begin(),ikinci.end(),pa)-ikinci.begin();
	if(node==(int)ikinci.size()||ikinci[node].f!=x) return 0;
	//cout<<a-x<<"  "<<ikinci[node].f<<" "<<ikinci[node].s<<endl;
	int fark=a-x;

	for(int i=0;i<M;i++){
		if((fark&(1<<i))){
			node=lca[node][i];
		}
	}
	x=ikinci[node].f, y=ikinci[node].s;
	//cout<<x<<" "<<y<<endl;
	if(x==a&&y<=b)return 1;
	return 0;
}

signed main(){
	//lalala;
	int r,c,n;cin>>r>>c>>n;
	vector<pair<int,int>> v;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		v.pb({b,a});
		ikinci.pb({a,b});
	}
	sort(v.begin(),v.end());
	sort(ikinci.begin(),ikinci.end());
	for(int i=0;i<(int)ikinci.size();i++){
		if(gittik[i])continue;
		dfs(i,ikinci[i].f,ikinci[i].s);
	}
	doldur();
	int q;cin>>q;
	while(q--){
		int x,y,a,b;cin>>x>>y>>a>>b;
		if(x>a||y>b){
			cout<<"No"<<endl;
			continue;
		}
		if(x==a){
			cout<<"Yes"<<endl;
			continue;
		}
		int ok=qua(x,y,a,b);
		if(ok)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3148 KB 200 token(s): yes count is 21, no count is 179
2 Correct 7 ms 3372 KB 200 token(s): yes count is 70, no count is 130
3 Correct 5 ms 2396 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 139 ms 57260 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 142 ms 57060 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 139 ms 56772 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 139 ms 57252 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 633 ms 67860 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 633 ms 67740 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 613 ms 67696 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 614 ms 67644 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 585 ms 67620 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 606 ms 67624 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 15 ms 2136 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 16 ms 2140 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 18 ms 2280 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 15 ms 2136 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 15 ms 2140 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 15 ms 2284 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 660 ms 67748 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 699 ms 67748 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 636 ms 67748 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 693 ms 67720 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 613 ms 67664 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 621 ms 67920 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 630 ms 67900 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 651 ms 67996 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 749 ms 67712 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 682 ms 67748 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 706 ms 67752 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 628 ms 67752 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 619 ms 67816 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 725 ms 67748 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 593 ms 67748 KB 200000 token(s): yes count is 129674, no count is 70326