#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 200005
#define fi first
#define se second
int r,c,n,timer;
vector<int> v[lim];
vector<pair<int,int>> vy;
int xm[lim],ym[lim];
int tut[lim];
map<int,int> mp;
set<int> st;
map<pair<int,int>,int> dp;
inline int f(int x,int y,int tx,int ty){
if(x>r || y>c)return 0;
if(x==tx && y<=ty)return 1;
if(dp.find({x,y})!=dp.end())return dp[{x,y}];
int cev=0;
for(auto a:v[x]){
if(a<y || a>ty)continue;
cev+=f(x+1,a,tx,ty);
}
return dp[{x,y}]=cev;
}
inline void solve(int q){
FOR{
st.insert(xm[i]);
}
for(auto x:st){
mp[x]=++timer;
tut[timer]=x;
}
FOR{
v[mp[xm[i]]].push_back(ym[i]);
}
for(int i=1;i<=timer;i++){
sort(v[i].begin(),v[i].end());
}
while(q--){
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
if(mp.find(x1)==mp.end()){
cout<<"No"<<'\n';
continue;
}
int tut=lower_bound(v[mp[x1]].begin(),v[mp[x1]].end(),y1)-v[mp[x1]].begin();
if(tut>=v[mp[x1]].size()){
cout<<"No"<<'\n';
continue;
}
if(v[mp[x1]][tut]<=y2){
cout<<"Yes"<<'\n';
}
else cout<<"No"<<'\n';
}
}
int32_t main(){
faster
cin>>r>>c>>n;
FOR{
cin>>xm[i]>>ym[i];
vy.push_back({xm[i],ym[i]});
}
sort(vy.begin(),vy.end());
int q;cin>>q;
if(q<=5000){
while(q--){
int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
bool stop=0;
if(x1==x2 && y1<=y2){
cout<<"Yes"<<'\n';
continue;
}
for(int i=0;i<vy.size();i++){
if(vy[i].fi<x1){
continue;
}
if(vy[i].fi==x1 && y1<=vy[i].se){
x1++;
y1=vy[i].se;
}
if(x1==x2 && y1<=y2){
stop=1;
break;
}
}
if(stop){
cout<<"Yes"<<'\n';
}
else cout<<"No"<<'\n';
}
}
else{
solve(q);
}
return 0;
}
Compilation message
trampoline.cpp: In function 'void solve(long long int)':
trampoline.cpp:70:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
70 | if(tut>=v[mp[x1]].size()){
| ~~~^~~~~~~~~~~~~~~~~~
trampoline.cpp: In function 'int32_t main()':
trampoline.cpp:101:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
101 | for(int i=0;i<vy.size();i++){
| ~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
10076 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
4 ms |
10076 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
4 ms |
9820 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
411 ms |
15732 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
447 ms |
14804 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
352 ms |
15056 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
444 ms |
15316 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
145 ms |
16576 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
145 ms |
17088 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
158 ms |
15804 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
216 ms |
16268 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
223 ms |
16316 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
355 ms |
24512 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
9816 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
16 ms |
9900 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
17 ms |
9816 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
15 ms |
9816 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
22 ms |
9816 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
18 ms |
9820 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
400 ms |
25832 KB |
expected NO, found YES [23rd token] |
2 |
Halted |
0 ms |
0 KB |
- |