Submission #1027811

#TimeUsernameProblemLanguageResultExecution timeMemory
1027811vjudge1Trampoline (info1cup20_trampoline)C++17
43 / 100
564 ms14164 KiB
#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; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...