#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9
// #define fisier 1
using namespace std;
typedef long long ll;
int r, c, n, q;
pair<int, int> p[200002];
int lvl[200002];
int anc[20][200002];
int cb(pair<int, int> x)
{
int st = 1;
int dr = n;
int ans = 0;
while(st <= dr)
{
int mid = (st + dr) / 2;
if(p[mid] >= x)
ans = mid, dr = mid - 1;
else
st = mid + 1;
}
return ans;
}
int kthanc(int a, int stp)
{
for(int i = 19; i >= 0; --i)
if(stp >= (1<<i))
a = anc[i][a], stp -= (1<<i);
return a;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> r >> c >> n;
for(int i = 1; i <= n; ++i)
cin >> p[i].fi >> p[i].se;
sort(p + 1, p + n + 1);
for(int i = n; i >= 1; --i)
{
int nxttr = cb({p[i].fi + 1, p[i].se});
if(p[nxttr].fi == p[i].fi + 1)
{
lvl[i] = lvl[nxttr] + 1;
anc[0][i] = nxttr;
for(int j = 1; j <= 19; ++j)
anc[j][i] = anc[j-1][anc[j-1][i]];
}
}
cin >> q;
for(; q; --q)
{
int xa, ya, xb, yb;
cin >> xa >> ya >> xb >> yb;
if(xa > xb || ya > yb)
{
cout << "No\n";
continue;
}
if(xa == xb)
{
cout << "Yes\n";
continue;
}
int nxttr = cb({xa, ya});
if(p[nxttr].fi > xa || p[nxttr].se > yb)
{
cout << "No\n";
continue;
}
if(lvl[nxttr] < xb - xa - 1)
{
cout << "No\n";
continue;
}
int poz = kthanc(nxttr, xb - xa - 1);
if(p[poz].fi <= xb && p[poz].se <= yb)
{
cout << "Yes\n";
continue;
}
cout << "No\n";
continue;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1260 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
5 ms |
1536 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
4 ms |
1132 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
20332 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
92 ms |
20204 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
96 ms |
19948 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
91 ms |
20204 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
237 ms |
30828 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
239 ms |
30728 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
247 ms |
30700 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
247 ms |
30956 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
244 ms |
30836 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
241 ms |
30700 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1260 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
6 ms |
1260 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
7 ms |
748 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
6 ms |
1260 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
6 ms |
1260 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
7 ms |
1260 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
354 ms |
30828 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
343 ms |
30860 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
264 ms |
30956 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
363 ms |
30700 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
291 ms |
30828 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
262 ms |
30956 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
277 ms |
30956 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
253 ms |
30828 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
356 ms |
30828 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
361 ms |
30828 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
393 ms |
30828 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
238 ms |
30828 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
249 ms |
30828 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
300 ms |
30956 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
238 ms |
30956 KB |
200000 token(s): yes count is 129674, no count is 70326 |