This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define int long long int
#define endl '\n'
#define N 210
#define M 400100
#define big 2147483647
#define bigg 9223372036854775807
#define pb push_back
#define p push
#define ins insert
#define f first
#define s second
int arr[N][N],green[N][N];
int r,c;
int dfs(int x,int y,int a,int b){
queue<pair<int,int>> q;
q.p({x,y});
while(q.size()){
x=q.front().f,y=q.front().s;
q.pop();
if(arr[x][y])continue;
arr[x][y]=1;
if(x==a&&y==b)return 1;
if(y!=c&&arr[x][y+1]==0){
q.p({x,y+1});
}
if(x!=r&&arr[x+1][y]==0&&green[x][y]){
q.p({x+1,y});
}
}
return 0;
}
void solve(){
memset(green,0,sizeof(green));
int n;cin>>r>>c>>n;
vector<int> yedek;
for(int i=0;i<n;i++){
int a,b;cin>>a>>b;
green[a][b]=1;
}
int q;cin>>q;
while(q--){
memset(arr,0,sizeof(arr));
int x,y,a,b;cin>>x>>y>>a>>b;
int ok=dfs(x,y,a,b);
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
signed main(){
lalala;
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |