Submission #675300

# Submission time Handle Problem Language Result Execution time Memory
675300 2022-12-27T03:53:08 Z vjudge1 Trampoline (info1cup20_trampoline) C++17
100 / 100
1090 ms 55092 KB
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define eb emplace_back
#define PI 3.14159265359
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define BIT(x,i) (1&((x)>>(i)))
#define MASK(x) (1LL<<(x))
#define task "tnc"
using namespace std;
typedef long long ll;
const ll INF=1e18;
const int maxn=1e6+5;
const int mod=1e9+7;
const int mo=998244353;
using pi=pair<ll,ll>;
using vi=vector<ll>;
using pii=pair<pair<ll,ll>,ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int r,c;
int n,t;
pair<int,int>z[200005];
pair<int,int>k[200005][19];
map<int,vector<pair<int,int>>>p;
vector<int>q;
signed main()
{
	cin.tie(0),cout.tie(0)->sync_with_stdio(0);
    cin>>r>>c;
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>z[i].fi>>z[i].se;
    	q.pb(z[i].fi);
    	p[z[i].fi].pb({z[i].se,i});
    }
    for(auto v:p){
        p[v.fi].pb({1e9+5,0});
    	sort(p[v.fi].begin(),p[v.fi].end());
    }
    z[0]={1e9+5,1e9+5};
    for(int i=1;i<=n;i++){
    	if(p[z[i].fi+1].size()==0)k[i][0]={1e9+5,0};
    	else{
    		int dit=lower_bound(p[z[i].fi+1].begin(),p[z[i].fi+1].end(),mp(z[i].se,0))-p[z[i].fi+1].begin();
    		//cout<<i<<" "<<q[dit].fi<<" "<<q[dit].se<<"\n";
    		k[i][0]={p[z[i].fi+1][dit].fi,p[z[i].fi+1][dit].se};
    	}
    }
    k[0][0]={1e9+5,0};
    for(int j=1;j<=18;j++){
    	for(int i=1;i<=n;i++){
    		k[i][j]=k[k[i][j-1].se][j-1];
    		if(k[i][j-1].fi==1e9+5 || k[i][j].se==0)k[i][j]={1e9+5,0};
    	}
	}
	int t;
	cin>>t;
	while(t--){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		if(x1==x2 && y1<=y2){
			cout<<"Yes\n";
		}
		else{
			int high=x2-x1-1;
			if(p[x1].size()==0){
				cout<<"No\n";
				continue;
			}
			
			int d=lower_bound(p[x1].begin(),p[x1].end(),mp(y1,0))-p[x1].begin();
			int st=p[x1][d].se;
			if(p[x1][d].fi==1e9+5){
				cout<<"No\n";
				continue;
			}
			for(int i=18;i>=0;i--){
				if((1<<i)&high){
					st=k[st][i].se;

				}
			}
			if(z[st].se<=y2){
				cout<<"Yes\n";
			}
			else{
				cout<<"No\n";
			}	
		}
	}
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 9 ms 1876 KB 200 token(s): yes count is 21, no count is 179
2 Correct 6 ms 2004 KB 200 token(s): yes count is 70, no count is 130
3 Correct 5 ms 1492 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 224 ms 35488 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 211 ms 35524 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 186 ms 34652 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 209 ms 35496 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 242 ms 35592 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 294 ms 35544 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 277 ms 35316 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 391 ms 36024 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 398 ms 35912 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 679 ms 42764 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1236 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 8 ms 1264 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 11 ms 2000 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 6 ms 1236 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 12 ms 1364 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 1252 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 981 ms 44528 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 767 ms 38212 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 398 ms 35212 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1090 ms 55092 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 654 ms 42508 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 383 ms 35864 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 356 ms 35864 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 360 ms 35356 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 907 ms 42808 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 874 ms 43176 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 938 ms 50660 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 258 ms 35312 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 294 ms 35352 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 462 ms 35792 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 337 ms 35552 KB 200000 token(s): yes count is 129674, no count is 70326