# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1144930 | KasymK | Trampoline (info1cup20_trampoline) | C++20 | 2103 ms | 282612 KiB |
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 2505;
bool vis[N][N];
int main(){
int r, c, n;
scanf("%d%d%d", &r, &c, &n);
auto is=[&](int a, int b) -> bool {
return (a>=1 and a<=r and b>=1 and b<=c);
};
while(n--){
int a, b;
scanf("%d%d", &a, &b);
vis[a][b]=1;
}
int q;
scanf("%d", &q);
while(q--){
int x, y, x1, y1;
scanf("%d%d%d%d", &x, &y, &x1, &y1);
queue<pii> q;
q.push({x, y});
bool did=0;
while(!q.empty()){
pii P=q.front();
q.pop();
if(P.ff==x1 and P.ss==y1){
did=1;
break;
}
if(vis[P.ff][P.ss]){
if(is(P.ff+1, P.ss))
q.push({P.ff+1, P.ss});
if(is(P.ff, P.ss+1))
q.push({P.ff, P.ss+1});
continue;
}
if(is(P.ff, P.ss+1))
q.push({P.ff, P.ss+1});
}
puts(did?"Yes":"No");
}
return 0;
}
Compilation message (stderr)
# | 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... |