#include <bits/stdc++.h>
#define ll long long
#define sz size()
#define pb push_back
#define all(x) x.begin() , x.end()
using namespace std;
const int N = 2505 ;
int r , c , n ;
map<pair<int,int> , int > mp ;
bool bfs(int xx , int yy , int endx , int endy ){
queue<pair<int,int> > q ;
q.push({xx , yy}) ;
while (q.size())
{
auto &[x,y] = q.front() ;
q.pop() ;
if(x == endx && y <= endy ) {return 1 ;}
if(mp[{x,y}]){
if(x+1 <= r ){
q.push({x+1 , y}) ;
}
}
else {
if(y+1 <= c ) {
q.push({x , y + 1 });
}
}
}
return 0 ;
}
int main()
{
cin >> r >> c >> n ;
for (int i = 0; i < n; i++)
{
int a, b ; cin >> a >> b;
mp[{a,b}]=1;
}
int t ; cin >> t;
for (int i = 0; i < t; i++)
{
int sx , sy , ex , ey ; cin >> sx >> sy >> ex >> ey;
bool ok = bfs(sx , sy , ex, ey) ;
if(ok)cout<<"Yes\n" ; else cout<<"No\n";
}
return 0;
}
/*
4 4 3
1 1
2 1
3 4
1
1 1 4 3
*
*
*
* */
Compilation message
trampoline.cpp: In function 'bool bfs(int, int, int, int)':
trampoline.cpp:15:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
15 | auto &[x,y] = q.front() ;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1112 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
9 ms |
1116 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
7 ms |
1116 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1020 ms |
78088 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
932 ms |
77392 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
517 ms |
13136 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
1557 ms |
69644 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2065 ms |
483064 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2068 ms |
576696 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2036 ms |
499792 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |