#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());
}
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2065 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2079 ms |
3652 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2069 ms |
5780 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2069 ms |
588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2065 ms |
5940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |