#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define T int t; cin >> t; while(t--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 1e5 + 5;
const int M = 1e3 + 3;
const int inf = 1e18;
const int mod = 1e9 + 7;
int r, c, n, q;
map<int, set<int>> mp;
map<pair<int, int>, int> comNum;
void dfs(int y, int x, int comp) {
comNum[{y, x}] = comp;
auto it = mp[y].upper_bound(x);
if (it != mp[y].end()) dfs(y, *it, comp);
it = mp[y + 1].lower_bound(x);
if (it != mp[y + 1].end()) dfs(y + 1, *it, comp);
}
main() {
IOS
cin >> r >> c >> n;
for(int i = 1; i <= n; i++) {
int y, x;
cin >> y >> x;
mp[y].insert(x);
}
int comp = 0;
for(auto y: mp) {
for(auto x: y.S) {
if (comNum[{y.F, x}]) continue;
dfs(y.F, x, ++comp);
}
}
cin >> q;
while(q--) {
int y1, x1, y2, x2;
cin >> y1 >> x1 >> y2 >> x2;
if (y1 == y2 && x1 <= x2) {
cout << "Yes\n";
continue;
}
if (x1 > x2) {
cout << "No\n";
continue;
}
auto it = mp[y1].lower_bound(x1);
if (it == mp[y1].end()) {
cout << "No\n";
continue;
}
x1 = *it;
it = mp[y2].upper_bound(x2);
if (it != mp[y2].begin()) {
it--;
if (comNum[{y1, x1}] == comNum[{y2, *it}]) {
cout << "Yes\n";
continue;
}
}
it = mp[y2 - 1].upper_bound(x2);
if (it != mp[y2 - 1].begin()) {
it--;
if (comNum[{y1, x1}] == comNum[{y2 - 1, *it}]) {
cout << "Yes\n";
continue;
}
}
cout << "No\n";
}
}
Compilation message
trampoline.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
25 | main() {
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2091 ms |
724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2086 ms |
11716 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2029 ms |
14116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2094 ms |
804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2043 ms |
40468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |