#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <utility>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 200007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
set < pair < pair < int,int >, int > > s;
pair <int,int> a[M];
int r, c, n, nxt[M][22];
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> r >> c >> n;
for(int i = 1; i <= n; ++i) cin >> a[i].F >> a[i].S;
sort(a + 1, a + n + 1);
for(int i = 1; i <= n; ++i){
while(s.size() && (*s.begin()).F.F < a[i].F - 1 ) s.erase(s.begin());
while(s.size()){
pair < pair <int,int>, int > p = *s.begin();
if(p.F.F == a[i].F - 1 && p.F.S <= a[i].S){
nxt[p.S][0] = i;
s.erase(s.begin());
}
else break;
}
s.insert({a[i], i});
}
for(int j = 1; j <= 20; ++j)
for(int i = 1; i <= n; ++i)
nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
// for(int i = 1; i <= n; ++i){
// cout << a[i].S << " " << a[i].F << endl;
// for(int j = 0; j < 5; ++j) cout << nxt[i][j] << " ";
// cout << endl;
// }
int q;
cin >> q;
while(q--){
pair <int,int> st, en;
cin >> st.F >> st.S >> en.F >> en.S;
if(st.F == en.F){
cout << "Yes\n";
continue;
}
int x = lower_bound(a + 1, a + n + 1, st) - a;
if(a[x].F > st.F){
cout << "No\n";
continue;
}
for(int i = 20; i >= 0; --i){
if(nxt[x][i] == 0) continue;
if(a[nxt[x][i]].F <= en.F) x = nxt[x][i];
}
if((a[x].F == en.F || a[x].F + 1 == en.F) && a[x].S <= en.S) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1100 KB |
expected YES, found NO [68th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
130 ms |
19104 KB |
expected YES, found NO [1822nd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
257 ms |
35144 KB |
expected YES, found NO [4th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
844 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
331 ms |
27300 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |