Submission #392165

# Submission time Handle Problem Language Result Execution time Memory
392165 2021-04-20T15:16:57 Z keta_tsimakuridze Trampoline (info1cup20_trampoline) C++14
0 / 100
1205 ms 193764 KB
#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
using namespace std;
const int N=2e5+5,mod=1e9+7,Inf=1e15;
int t,tree[15*N],le_[15*N],ri_[15*N],cur,root[N],n,R,C;
pair<int,int>p[N],a[N];
map<int,int> ind;
set<int> s[N];
void build(int u,int l,int r){
	tree[u]=Inf;
	if(l==r) {
		return;
	}
	cur++;
	le_[u] = cur;
	cur++;
	ri_[u] = cur;
	int mid=(l+r)/2;
	build(le_[u],l,mid);
	build(ri_[u],mid+1,r);
}
void update(int u,int ind,int l,int r,int val){
	if(l>ind || r<ind) return;
	if(l==r){
		tree[cur]=val;
		return;
	}
	int mid=(l+r)/2,x=cur;
	le_[x]=le_[u];
	ri_[x]=ri_[u];
	cur++;
	if(ind<=mid) {
		le_[x]=cur;
	}
	else ri_[x]=cur;
	update(le_[u],ind,l,mid,val);
	update(ri_[u],ind,mid+1,r,val);
	tree[x] = min(tree[le_[x]],tree[ri_[x]]);
}
int getans(int u,int ind,int l,int r){
	if(l>ind || r<ind) return Inf;
	if(l==r) {
		return tree[u];
	}
	int mid=(l+r)/2;
	return  min(getans(le_[u],ind,l,mid),getans(ri_[u],ind,mid+1,r));
}
 main(){
	// t=1;
	cin>>R>>C>>n;

	swap(R,C);
	for(int i=1;i<=n;i++){
		cin>>p[i].s>>p[i].f;
	}
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++){
		a[i].f = p[i].s;
	}
	int idx = 0;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(a[i].f!=a[i-1].f) idx++;
		ind[a[i].f] = idx;
	}
	root[n+1]=1;
	cur=1;
	build(1,1,n);
	for(int i=n;i>=1;i--){
		if(s[ind[p[i].s+1]].upper_bound(p[i].f-1) != s[ind[p[i].s+1]].end()) {
			int bef = root [*s[ind[p[i].s+1]].upper_bound(p[i].f-1) ];
			root[i] =cur+1;
			update(bef,ind[p[i].s],1,n,p[i].f);
		}
		else root[i]=n+1;
		s[ind[p[i].s]].insert(i);
	}	
	cin>>t;
	while(t--){
		int x,y,x2,y2;
		cin>>x>>y>>x2>>y2;
		swap(x,y);
		swap(x2,y2);
		if(s[ind[y]].upper_bound(x-1)==s[ind[y]].end()){
			if(y == y2) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
		else {
			int aft = *s[ind[y]].upper_bound(x-1);
			if(getans(root[aft],ind[y2-1],1,n) <= x2) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
	}
}

Compilation message

trampoline.cpp:50:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 |  main(){
      |       ^
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 13516 KB expected NO, found YES [2nd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 512 ms 193764 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 929 ms 48524 KB expected YES, found NO [4th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 10656 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1205 ms 53440 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -