#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 2e5+5;
const int M = 1e2+2;
const int mod = 1e9+7;
const ll base = 75;
const int inf = 1e9;
int m, n, t, b[N], d[N], lab[N], q;
int k, a[N], dp[N], P[N][20];
ll ans, tong;
vector<int> adj[N];
vector<int> vi;
string s[N];
bool vis[N];
ll pw(ll k, ll n)
{
ll total = 1;
for(; n; n >>= 1)
{
if(n&1)total = total * k % mod;
k = k * k % mod;
}
return total;
}
void add(int &x, int y)
{
x += y;
if(x >= mod)x -= mod;
}
int findp(int u)
{
return lab[u] < 0 ? u : lab[u] = findp(lab[u]);
}
void hop(int u, int v)
{
u = findp(u);
v = findp(v);
if(u == v)return;
if(lab[u] > lab[v])swap(u, v);
lab[u] += lab[v];
lab[v] = u;
}
int C(int u, int v)
{
if(u > v)return 0;
return 1ll * a[v] * b[u] % mod * b[v-u] % mod;
}
pii p[N];
void sol()
{
cin >> n >> m >> k;
for(int i = 1; i <= k; i ++)cin >> p[i].fi >> p[i].se;
sort(p+1, p+1+k);
for(int i = 1; i <= k; i ++)
{
int j = lower_bound(p+1, p+1+k, make_pair(p[i].fi+1, p[i].se)) - p;
if(j <= n && p[j].fi == p[i].fi+1)P[i][0] = j;
//cout << i <<" "<<j<<'\n';
}
for(int j = 1; j <= 18; j ++)
{
for(int i = 1; i <= k; i ++)P[i][j] = P[P[i][j-1]][j-1];
}
cin >> q;
while(q -- > 0)
{
pii l, r;
cin >> l.fi >> l.se >> r.fi >> r.se;
if(l.fi > r.fi || l.se > r.se)cout << "No" << '\n';
else if(l.fi == r.fi)cout << "Yes" << '\n';
else
{
int i = lower_bound(p+1, p+1+k, l) - p;
if(i > k || l.fi != p[i].fi)cout << "No" << '\n';
else
{
for(int j = 18; j >= 0; j --)
{
if(P[i][j] && p[P[i][j]].fi < r.fi-1)i = P[i][j];
}
if(P[i][0] && p[P[i][0]].fi == r.fi-1 && p[P[i][0]].se <= r.se)cout << "Yes" << '\n';
else cout << "No" << '\n';
}
}
}
}
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
#define task "test"
if(fopen(task".inp", "r"))
{
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int test = 1;
//cin >> test;
while(test -- > 0)sol();
return 0;
}
Compilation message
trampoline.cpp: In function 'int main()':
trampoline.cpp:104:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
104 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:105:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
105 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
11964 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
95 ms |
28484 KB |
expected YES, found NO [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
222 ms |
29008 KB |
expected YES, found NO [4th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
11724 KB |
expected YES, found NO [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
351 ms |
29180 KB |
expected YES, found NO [450th token] |
2 |
Halted |
0 ms |
0 KB |
- |