// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define pii pair<int,int>
const int mod=998244353;
const int maxn=200005;
const int maxl=20;
const int maxa=1000005;
int power(int a,int n){
int res=1;
while(n){
if(n&1) res=res*a%mod;
a=a*a%mod;n>>=1;
}
return res;
}
int r,c,n,nxt[maxn][maxl];
pii x[maxn];
map<int,vector<pii>> mp;
int cal(int p,int i){
int cur=x[p].first+(1<<(i-1)),y=nxt[p][i-1];
if(y==-1) return -1;
auto it=lower_bound(mp[cur].begin(),mp[cur].end(),make_pair(y,0));
if(it==mp[cur].end()) return -1;
return nxt[it->second][i-1];
}
bool check(int x1,int y1,int x2,int y2){
if(x1>x2) return false;
if(x1==x2){
if(y1<=y2) return true;
else return false;
}
for(int i=0;i<18;i++){
if((x2-x1)&(1<<i)){
auto it=lower_bound(mp[x1].begin(),mp[x1].end(),make_pair(y1,0));
if(it==mp[x1].end()) return false;
y1=nxt[it->second][i];x1+=(1<<i);
}
if(y1==-1) return false;
}
if(y1<=y2) return true;
else return false;
}
void solve(){
int r,c,n;cin >> r >> c >> n;
for(int i=1;i<=n;i++) cin >> x[i].first >> x[i].second;
sort(x+1,x+n+1);
for(int i=1;i<=n;i++){mp[x[i].first].push_back({x[i].second,i});nxt[i][0]=x[i].second;}
for(int i=1;i<18;i++){
for(int j=1;j<=n;j++) nxt[j][i]=cal(j,i);
}
int t;cin >> t;
while(t--){
int x1,y1,x2,y2;cin >> x1 >> y1 >> x2 >> y2;
if(check(x1,y1,x2,y2)) cout << "Yes\n";
else cout << "No\n";
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
int t=1;//cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1108 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
8 ms |
1288 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
5 ms |
1048 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
20172 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
168 ms |
20300 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
200 ms |
19588 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
186 ms |
20220 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
230 ms |
20292 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
256 ms |
20204 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
259 ms |
19892 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
356 ms |
20584 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
368 ms |
20492 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
706 ms |
26456 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
852 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
8 ms |
852 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
7 ms |
1620 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
5 ms |
852 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
13 ms |
980 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
5 ms |
852 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1060 ms |
27720 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
766 ms |
22256 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
306 ms |
19916 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
1954 ms |
40324 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
697 ms |
27132 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
282 ms |
20320 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
319 ms |
20304 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
292 ms |
19848 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
1037 ms |
26492 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
1063 ms |
26564 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
1702 ms |
32892 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
265 ms |
20004 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
236 ms |
20296 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
518 ms |
20544 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
267 ms |
20376 KB |
200000 token(s): yes count is 129674, no count is 70326 |