#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
using namespace std;
const int N=4e5+5,mod=1e9+7,Inf=1e15;
int t,tree[25*N],le_[25*N],ri_[25*N],cur,root[N],n,R,C;
pair<int,int>p[N],a[N];
map<int,int> ind;
set<pair<int,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(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// t=1;
cin>>R>>C>>n;
swap(R,C);
for(int i=1;i<=n;i++){
cin>>p[i].f>>p[i].s;
}
sort(p+1,p+n+1);
for(int i=1;i<=n;i++){
a[i].f = p[i].f;
}
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--){int bef=1;
if(s[ind[p[i].f+1]].upper_bound({p[i].s,0}) != s[ind[p[i].f+1]].end()) {
bef = root [(*s[ind[p[i].f+1]].upper_bound({p[i].s,0})).s ];
}
cur++;root[i] =cur;
update(bef,ind[p[i].f],1,n,p[i].s);
s[ind[p[i].f]].insert({p[i].s,i});
}
cin>>t;
while(t--){
int x,y,x2,y2;
cin>>x>>y>>x2>>y2;
swap(x,y);
swap(x2,y2);
if(y==y2 && x<=x2) cout<<"Yes"<<" ";
else
if(s[ind[y]].upper_bound({x,0})==s[ind[y]].end()){
cout<<"No"<<" ";
}
else {
int aft =( *s[ind[y]].upper_bound({x,0})).s;
if(getans(root[aft],ind[y2-1],1,n) <= x2) cout<<"Yes"<< " ";
else cout<<"No"<< " ";
}
}
}
Compilation message
trampoline.cpp:50:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
50 | main(){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
23372 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
26 ms |
23952 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
19 ms |
22476 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
254 ms |
136752 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
273 ms |
136820 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
242 ms |
136732 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
258 ms |
136824 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
612 ms |
138880 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
623 ms |
138796 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
616 ms |
137344 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
676 ms |
137464 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
673 ms |
137428 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
795 ms |
141528 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
21452 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
23 ms |
21692 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
26 ms |
22404 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
23 ms |
21840 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
25 ms |
21816 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
22 ms |
21836 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
898 ms |
142452 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
793 ms |
138560 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
684 ms |
149044 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
1097 ms |
161540 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
980 ms |
154028 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
727 ms |
150580 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
695 ms |
150488 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
693 ms |
149052 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
912 ms |
153192 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
941 ms |
153236 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
1054 ms |
157404 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
643 ms |
150500 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
655 ms |
150580 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
681 ms |
149212 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
673 ms |
148868 KB |
200000 token(s): yes count is 129674, no count is 70326 |