//we are all lost trying to be someone.
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define reve(x) reverse(x.begin(),x.end())
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
const ll MAX=3*(1e4+100);
const ll mod=1e9+7;
const ll inf=1e18+7;
ll n, m;
bool vst[210][210];
ll A[210][210];
ii mobs[3]={{0,1},{1,0}};
bool awa(ll i, ll j){
return i<=n and i>=1 and j<=m and j>=1;
}
void dfs(ll i, ll j){
vst[i][j]=true;
if(A[i][j]==1){
for(ll k=0; k<2; k++){
ll x=i+mobs[k].ff;
ll y=j+mobs[k].ss;
if(awa(x,y) and !vst[x][y]){
dfs(x,y);
}
}
}
else{
for(ll k=0; k<1; k++){
ll x=i+mobs[k].ff;
ll y=j+mobs[k].ss;
if(awa(x,y) and !vst[x][y]){
dfs(x,y);
}
}
}
return;
}
void clen(){
for(ll i=0; i<=n; i++){
for(ll j=0; j<=m; j++){
vst[i][j]=false;
}
}
}
int main(){
ll t;
cin>>n>>m>>t;
ll a, b;
while(t--){
cin>>a>>b;
A[a][b]=1;
}
/*for(ll i=1; i<=n; i++){
for(ll j=0; j<=m; j++){
cout<<A[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;*/
cin>>t;
while(t--){
ll x1, y1, x2, y2;
cin>>x1>>y1>>x2>>y2;
clen();
dfs(x1,y1);
if(vst[x2][y2]){
cout<<"Yes"<<'\n';
}
else cout<<"No"<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
724 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
13 ms |
576 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
6 ms |
684 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |