#include <bits/stdc++.h>
using namespace std;
int main(){
int r,c,n;
cin>>r>>c>>n;
map < pair <int,int> ,int> mp;
while(n--){
int x,y;
cin>>x>>y;
pair <int,int> p=make_pair(x,y);
mp[p]=1;
}
int t;
cin>>t;
while(t--){
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
vector <vector <int> > d(r+1,vector <int> (c+1,-1));
queue <pair <int,int> > q;
d[x1][y1]=0;
pair <int,int> p=make_pair(x1,y1);
q.push(p);
while(!q.empty()){
pair <int,int> curv=q.front();
q.pop();
if(curv.first+1<=r){
pair <int,int> p=make_pair(curv.first+1,curv.second);
if(mp[curv]==1 && d[curv.first+1][curv.second]==-1){
d[curv.first+1][curv.second]=1;
q.push(p);
}
}
if(curv.second+1<=c){
pair <int,int> p=make_pair(curv.first,curv.second+1);
if(d[curv.first][curv.second+1]==-1){
d[curv.first][curv.second+1]=1;
q.push(p);
}
}
}
if(d[x2][y2]==1)
cout<<"Yes\n";
else
cout<<"No\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
2636 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
128 ms |
2284 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
54 ms |
2676 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2083 ms |
228972 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
811 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
389 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
638 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |