답안 #675285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
675285 2022-12-27T03:49:20 Z anhduc2701 Trampoline (info1cup20_trampoline) C++17
11 / 100
813 ms 44448 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,0};
    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]={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;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1876 KB expected NO, found YES [3rd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 236 ms 35560 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 282 ms 35608 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 282 ms 35476 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 283 ms 35264 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 417 ms 35900 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 389 ms 35908 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 662 ms 42728 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1236 KB expected NO, found YES [9th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 813 ms 44448 KB expected NO, found YES [12th token]
2 Halted 0 ms 0 KB -