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;
int r,c,n,t;
vector<int> adj[200*200];
int id(int i,int j){
return i*c + j;
}
int vis[200*200];
bool dfs(int u,int x,int c){
vis[u] = c;
if(u == x) return true;
for(int v:adj[u]){
if(vis[v] == c) continue;
if(dfs(v,x,c))
return true;
}
return false;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> r >> c >> n;
for(int i = 0; i < r; i++){
for(int j = 0; j < c - 1; j++){
adj[id(i,j)].push_back(id(i,j+1));
}
}
int x,y,a,b;
for(int i = 0; i < n; i++){
cin >> x >> y;
x--,y--;
if(x < r-1)
adj[id(x,y)].push_back(id(x+1,y));
}
cin >> t;
while(t--){
cin >> x >> y >> a >> b;
int cc = 1;
if(dfs(id(x-1,y-1), id(a-1,b-1), cc ) )
cout << "Yes\n";
else
cout << "No\n";
cc++;
}
return 0;
}
# | 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... |