#include <bits/stdc++.h>
using namespace std;
const int nx=2e5+5, kx=18;
int r, c, n, q, p[4], pa[nx][kx], x[nx], y[nx];
map<int, set<pair<int, int>>> mp;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>r>>c>>n;
for (int i=1; i<=n; i++) cin>>x[i]>>y[i], mp[x[i]].insert({y[i], i});
for (int i=1; i<=n; i++)
{
if (mp.find(x[i]+1)==mp.end()||mp[x[i]+1].lower_bound(make_pair(y[i], 0))==mp[x[i]+1].end()) pa[i][0]=i;
else pa[i][0]=mp[x[i]+1].lower_bound(make_pair(y[i], 0))->second;
}
for (int i=1; i<kx; i++) for (int j=1; j<=n; j++) pa[j][i]=pa[pa[j][i-1]][i-1];
cin>>q;
while (q--)
{
cin>>p[0]>>p[1]>>p[2]>>p[3];
if (p[0]>p[2]) cout<<"No\n";
else if (p[1]>p[3]) cout<<"No\n";
else if (p[0]==p[2]) cout<<"Yes\n";
else if (mp.find(p[0])==mp.end()||mp[p[0]].lower_bound(make_pair(p[1], 0))==mp[p[0]].end()) cout<<"No\n";
else
{
int st=mp[p[0]].lower_bound(make_pair(p[1], 0))->second;
for (int i=kx-1; i>=0; i--) if (x[pa[st][i]]<p[2]) st=pa[st][i];
if (y[st]<=p[3]) cout<<"Yes\n";
else cout<<"No\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
2908 KB |
expected NO, found YES [64th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
174 ms |
27540 KB |
expected NO, found YES [40th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
298 ms |
37900 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
300 ms |
37716 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
348 ms |
37660 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
391 ms |
37968 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
381 ms |
37976 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
425 ms |
43844 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2904 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
7 ms |
2908 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Incorrect |
7 ms |
3420 KB |
expected NO, found YES [26th token] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
493 ms |
45144 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
449 ms |
39556 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Incorrect |
357 ms |
37736 KB |
expected NO, found YES [194374th token] |
4 |
Halted |
0 ms |
0 KB |
- |