#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 200005
#define fi first
#define se second
vector<pair<int,int>> v[lim];
int x[lim],y[lim];
set<int> st;
map<int,int> mp;
int timer,l;
int up[lim][25];
int32_t main(){
faster
int r,c,n;cin>>r>>c>>n;
l=ceil(log2(n));
FOR{
cin>>x[i]>>y[i];
st.insert(x[i]);
}
for(auto a:st){
mp[a]=++timer;
}
FOR{
v[mp[x[i]]].push_back({y[i],i});
}
for(int i=1;i<=timer;i++){
sort(v[i].begin(),v[i].end());
}
FOR{
if(mp.find(x[i]+1)==mp.end())continue;
if(v[mp[x[i]+1]].back().fi<y[i])continue;
int tut=lower_bound(v[mp[x[i]+1]].begin(),v[mp[x[i]+1]].end(),make_pair(y[i],0ll))-v[mp[x[i]+1]].begin();
up[i][0]=v[mp[x[i]+1]][tut].se;
}
for(int i=1;i<=l;i++){
for(int j=1;j<=n;j++){
up[j][i]=up[up[j][i-1]][i-1];
}
}
int q;cin>>q;
while(q--){
int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
if(y1>y2){
cout<<"No"<<'\n';
continue;
}
if(x1==x2){
cout<<"Yes"<<'\n';
continue;
}
if(x1>x2){
cout<<"No"<<'\n';
continue;
}
if(v[mp[x1]].back().fi<y1){
cout<<"No"<<'\n';
continue;
}
int node=lower_bound(v[mp[x1]].begin(),v[mp[x1]].end(),make_pair(y1,0ll))-v[mp[x1]].begin();
node=v[mp[x1]][node].se;
for(int i=l;i>=0;i--){
if(up[node][i] && x[up[node][i]]<x2){
node=up[node][i];
}
}
if(y[node]<=y2)cout<<"Yes"<<'\n';
else cout<<"No"<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
12636 KB |
expected NO, found YES [64th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
162 ms |
53076 KB |
expected NO, found YES [40th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
52612 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
165 ms |
51832 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
190 ms |
52024 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
278 ms |
53284 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
277 ms |
53076 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
470 ms |
60588 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
12636 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
6 ms |
12892 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Incorrect |
8 ms |
12124 KB |
expected NO, found YES [26th token] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
535 ms |
62076 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
450 ms |
67156 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Incorrect |
195 ms |
63680 KB |
expected NO, found YES [194374th token] |
4 |
Halted |
0 ms |
0 KB |
- |