#include <iostream>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
#define pii pair<int, int>
vector<vector<int>>vec;
vector<bool>visit;
void dfs(int v) {
visit[v] = true;
for (auto u:vec[v]) {
if (!visit[u])
dfs(u);
}
}
int main() {
int r, c, n;
cin >> r >> c >> n;
set<pii>green;
int a, b;
for (int i = 0; i < n; i++) {
cin >> a >> b;
a--, b--;
green.insert({ a,b });
}
vec.resize(r * c);
visit.resize(r * c, false);
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
if (green.find({ i,j }) != green.end()) {
if (i != r - 1)
vec[i * c + j].push_back(i * c + j + 1);
if (j != c - 1)
vec[i * c + j].push_back((i + 1) * c + j);
}
else {
if (j != c - 1)
vec[i * c + j].push_back(i * c + j + 1);
}
}
}
int t;
cin >> t;
while (t--) {
int y1, x1, y2, x2;
cin >> y1 >> x1 >> y2 >> x2;
y1--, x1--, y2--, x2--;
dfs(y1 * c + x1);
if (visit[y2 * c + x2])
cout << "YES";
else
cout << "NO";
cout << endl;
visit.resize(0);
visit.resize(r * c, false);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
14 ms |
5836 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2115 ms |
355108 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
357 ms |
19496 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
972 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
304 ms |
19476 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |