이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 2520
//#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
bool arr[N][N],green[N][N];
//int hesap(int x,int y,int r,int c)
inline bool dfs(int x,int y,int a,int b,int r,int c){
queue<pair<int,int>> q;
q.p({x,y});
if(x>a)return 0;
if(y>b)return 0;
if(x==a)return 1;
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>b)continue;
if(x>a)continue;
if(x!=r&&arr[x+1][y]==0&&green[x][y]){
q.p({x+1,y});
continue;
}
if(y!=c&&arr[x][y+1]==0){
q.p({x,y+1});
}
}
return 0;
}
signed main(){
lalala;
int r,c,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,r,c);
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
# | 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... |