#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int n,m,k,q,link[200010];
pair<int,int>tr[200010];
int xb,yb,xe,ye;
int cb(int b,int e)
{
if(b>e)
return b;
int m=(b+e)/2;
if(tr[m].first<xb||tr[m].first==xb&&tr[m].second<yb)
return cb(m+1,e);
return cb(b,m-1);
}
ifstream in("test.in");
ofstream out("test.out");
int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
cin>>n>>m>>k;
for(int i=1;i<=k;++i)
cin>>tr[i].first>>tr[i].second;
sort(tr+1,tr+k+1);
tr[k+1]={1111111111,1111111111};
for(int i=1;i<=k;++i)
{
xb=tr[i].first+1;
yb=tr[i].second;
link[i]=cb(i+1,k);
if(tr[link[i]].first>tr[i].first+1)
link[i]=k+1;
}
cin>>q;
while(q--)
{
cin>>xb>>yb>>xe>>ye;
int poz=cb(1,k);
int l=xb,c=yb;
if(l<tr[poz].first)
poz=k+1;
while(l<xe)
{
l=tr[poz].first+1;
c=tr[poz].second;
poz=link[poz];
}
if(c<=ye)
cout<<"Yes"<<'\n';
else
cout<<"No"<<'\n';
}
return 0;
}
Compilation message
trampoline.cpp: In function 'int cb(int, int)':
trampoline.cpp:13:39: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
13 | if(tr[m].first<xb||tr[m].first==xb&&tr[m].second<yb)
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
460 KB |
expected NO, found YES [27th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
4604 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
59 ms |
4452 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
65 ms |
4156 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Incorrect |
73 ms |
4488 KB |
expected NO, found YES [1000th token] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
178 ms |
5652 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
186 ms |
4456 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
182 ms |
4352 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
182 ms |
4292 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
179 ms |
4404 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
177 ms |
4328 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
588 KB |
expected NO, found YES [17th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2049 ms |
3748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |