/*
ID: amr33311
LANG: C++
PROB: task
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define pb(x) push_back(x);
#define endl "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=3e5+7;
ll INF=INT_MAX,mod=1e9+7;
int t=1;
int x1 ,y3,y4, x2;
ll n,m,k;
bool arr[2510][2510]={0},vis[2510][2510]={0};
bool isvalid(ll x, ll y)
{
if(x>=n||y>=m||vis[x][y]) return 0;
return 1;
}
bool bfs()
{
vis[x1][y3] = 1;
queue< pair<ll,ll> > q;
q.push({x1,y3});
while(q.size())
{
ll curx=q.front().F,cury=q.front().S;
q.pop();
if(curx==x2&&cury==y4) return 1;
vis[curx][cury] = 1;
if(isvalid(curx+1,cury))
if(arr[curx][cury]==1) q.push({curx+1,cury});
if(isvalid(curx,cury+1))
q.push({curx,cury+1});
}
return 0;
}
void solve()
{
cin >> n >> m >> k;
for(int i =0 ; i < k; i++)
{
ll x,y; cin >> x >> y; x--, y--; arr[x][y]=1;}
ll g; cin >> g;
while(g--)
{
cin >> x1 >> y3 >> x2 >> y4;
x1--,y3--,x2--,y4--;
if(bfs()) cout << "YES" << endl; else cout << "NO" << endl;
memset(vis, 0 , sizeof vis);
}
}
int main(){
//freopen("friday.in","r",stdin);
//freopen("friday.out","w",stdout);
fast;
while(t--)
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2093 ms |
398312 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2078 ms |
103124 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |