#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ALL(v) v.begin(),v.end()
#define MASK(k) (1LL << (k))
#define BIT(x, i) (((x) >> (i)) & 1)
#define oo (ll)1e18
#define INF (ll)1e9
#define MOD (ll)(1007050321)
using namespace std;
template<class T1, class T2>
bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2>
bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2>
void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;}
template<class T1, class T2>
void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;}
template<class T>
void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}
const int MAX = 2e5 + 10, LOG = 18;
int R, C, N, Q;
int d[MAX][LOG];
int X[MAX], Y[MAX];
void solve(){
cin >> R >> C >> N;
map<int, vector<pair<int, int>>> mp;
for(int i = 1; i <= N; i++){
int x, y;
cin >> x >> y;
X[i] = x; Y[i] = y;
mp[x].push_back(make_pair(y, i));
}
for(auto o: mp){
sort(ALL(o.se));
}
for(int i = 1; i <= N; i++){
if(!mp.count(X[i] + 1)) continue;
auto it = lower_bound(ALL(mp[X[i] + 1]), make_pair(Y[i], 0));
if(it != mp[X[i] + 1].end()){
d[i][0] = it->se;
}
}
for(int j = 1; j < LOG; j++){
for(int i = 1; i <= N; i++){
d[i][j] = d[d[i][j - 1]][j - 1];
}
}
cin >> Q;
while(Q--){
int x, y, u, v; cin >> x >> y >> u >> v;
if(u < x){
cout << "No\n";
continue;
}
if(x == u && v >= y){
cout << "Yes\n";
continue;
}
auto it = lower_bound(ALL(mp[x]), make_pair(y, 0));
if(it == mp[x].end()){
cout << "No\n";
continue;
}
int c = it->se;
int delta = u - x - 1;
for(int i = 0; i < LOG; i++) if(BIT(delta, i)){
c = d[c][i];
}
if(c != 0 && Y[c] <= v) cout << "Yes\n";
else cout << "No\n";
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("numtable.inp","r",stdin);
// freopen("numtable.out","w",stdout);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1372 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
121 ms |
21012 KB |
expected YES, found NO [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
131 ms |
30804 KB |
expected YES, found NO [4th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1112 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
378 ms |
37924 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |