#include <bits/stdc++.h>
//#define DEBUG 1106
#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define p_q priority_queue
#define m_p make_pair
#define pii pair<int,int>
#define endl '\n'
#define INIT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define forn(i,n) for (int i = 0; i < n; i++)
#define forn1(i,n) for (int i = 1; i <= n; i++)
#define all(x) x.begin(),x.end()
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl;
#else
#define debug(x) 1106;
#endif
using namespace std;
const int N = 2e5+5;
const int M = 25;
const int inf = 1e9;
const int INF = 1e18;
const int MOD = 1e9+7;
int twok[N][M];
int row[N], col[N];
map<int,vector<int>> mp;
map<pii,int> id;
signed main() {
INIT
#ifdef DEBUG
freopen("input.txt", "r", stdin);
#endif
///////////
int r, c, n;
cin >> r >> c >> n;
forn1(i,n) {
cin >> row[i] >> col[i];
id[m_p(row[i],col[i])] = i;
mp[row[i]].pb(col[i]);
}
for(auto x: mp) {
sort(all(mp[x.ft]));
}
forn1(i,n) {
auto it = lower_bound(all(mp[row[i]+1]), col[i]);
if (it == mp[row[i]+1].end()) continue;
twok[i][0] = id[m_p(row[i]+1,*it)];
}
forn1(j,M-1) {
forn1(i,n) {
twok[i][j] = twok[twok[i][j-1]][j-1];
}
}
int q;
cin >> q;
while(q--) {
int x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
if(x1>x2 || y1>y2) {
cout << "No" << endl;
continue;
}
if(x1==x2) {
cout << "Yes" << endl;
continue;
}
auto it = lower_bound(all(mp[x1]),y1);
int u;
if (it == mp[x1].end()) u = 0;
else u = id[m_p(x1,*it)];
int dist = x2-x1-1;
forn(i,M) {
if(dist&(1<<i)) {
u = twok[u][i];
}
}
if(u==0 || col[u]>y2) cout << "No" << endl;
else cout << "Yes" << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
11 ms |
7260 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
7 ms |
7240 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
333 ms |
58192 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
328 ms |
58172 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
326 ms |
57284 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
334 ms |
58200 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
375 ms |
57760 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
442 ms |
58036 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
537 ms |
57936 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
556 ms |
58284 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
607 ms |
58448 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
735 ms |
64516 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4956 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
7 ms |
4956 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
10 ms |
4700 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
7 ms |
4956 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
9 ms |
4956 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
6 ms |
4956 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
920 ms |
65764 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
777 ms |
60644 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
495 ms |
57872 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
1084 ms |
77712 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
700 ms |
64692 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
535 ms |
58976 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
570 ms |
58400 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
485 ms |
57788 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
896 ms |
64396 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
946 ms |
64884 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
1033 ms |
70584 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
391 ms |
58052 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
468 ms |
57936 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
630 ms |
58704 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
467 ms |
57944 KB |
200000 token(s): yes count is 129674, no count is 70326 |