#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x<<' '<< x <<'\n'
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ro(i,n) for(i=n;i<=0;i--)
#define Ro(i,k,n) for(i=k;i<n;i--)
#define ll long long
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define vl vector<ll>
#define vpll vector<pll>
#define pb push_back
#define MEMINF 0x3f // ll 456e16, int 11e8
#define MEMINFB 0x7f // ll 919e16, int 21e8
#define MEMINFN 0x80 // ll -810e16, int -19e8
#define INF LLONG_MAX
#define MM <<" "<<
#define endl "\n"
int nx[200000][20]; // x,steps
int main(){
ios;
ll i,j,k,n,m,r,c,q;
int ind,x;
pll newpt;
cin >> r >> c >>n;
vpll v(n);
fo(i,n){
cin >> j >> k;
v[i] = {j,k};
}
sort(v.begin(),v.end());
auto it = v.begin();
fo(i,n){
pll find = {v[i].first+1,v[i].second};
it = lower_bound(it,v.end(),find);
if ( it ==v.end() || (*it).first >v[i].first+1) nx[i][0] = -1;
else nx[i][0] =(it-v.begin());
}
Fo(j,1,19){
fo(i,n) nx[i][j] = nx[nx[i][j-1]][j-1];
}
cin >> q;
fo(i,q){
bool ans = true;
ll x1,y1,x2,y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 > x2 || (x1==x2 && y1 > y2) ) ans = false;
else if (x1 == x2 && y1 <= y2) ans = true;
else{
int dx= x2-x1-1;
pll cur = {x1,y1};
auto it = lower_bound(v.begin(),v.end(),cur);
if (it == v.end() || (*it).first > cur.first) ans = false;
else {
ind = (it-v.begin());
x = 0;
while (dx){
if (dx&1) ind = nx[ind][x];
if (ind == -1) {ans = false; break;}
dx >>=1;
x++;
}
if (ans){ if (v[ind].second > y2) ans = false;}
}
}
if (ans) cout <<"Yes"<<endl;
else cout <<"No" <<endl;
}
}
Compilation message
trampoline.cpp: In function 'int main()':
trampoline.cpp:28:16: warning: unused variable 'm' [-Wunused-variable]
28 | ll i,j,k,n,m,r,c,q;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1160 KB |
expected NO, found YES [11th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
96 ms |
20836 KB |
expected NO, found YES [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
309 ms |
25568 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
266 ms |
25560 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
266 ms |
25484 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Runtime error |
102 ms |
40900 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1088 KB |
expected NO, found YES [104th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
102 ms |
42480 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |