#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;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
7000 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
29 ms |
7004 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
28 ms |
7000 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
558 ms |
14164 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
537 ms |
14092 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
547 ms |
9008 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
564 ms |
13904 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |