#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ff first
#define ss second
#define ll long long
using namespace std;
const int MAX=2e2+5;
int A[MAX][MAX];
int r,c;
bool vis[MAX][MAX];
void ini(){
for(int i=0;i<=r;i++){
for(int j=0;j<=c;j++){
vis[i][j]=0;
}
}
}
void bfs(int a,int b){
vis[a][b]=1;
queue<pair<int,int>>q;
q.push({a,b});
while(q.size()!=0){
int u=q.front().ff;
int v=q.front().ss;
q.pop();
if(A[u][v]){
if(v+1<=c and !vis[u][v+1]){
q.push({u,v+1});
vis[u][v+1]=1;
}
if(u+1<=r and !vis[u+1][v]){
q.push({u+1,v});
vis[u+1][v]=1;
}
}
else{
if(v+1<=c and !vis[u][v+1]){
q.push({u,v+1});
vis[u][v+1]=1;
}
}
}
}
void go(){
int n; cin>>r>>c>>n;
for(int i=0;i<n;i++){
int a,b; cin>>a>>b;
A[a][b]=1;
}
int t; cin>>t;
while(t--){
ini();
int a,b,c,d; cin>>a>>b>>c>>d;
bfs(a,b);
if(vis[c][d]) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
int main(){
fastio;
go();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
468 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
14 ms |
468 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
7 ms |
468 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |