Submission #524896

#TimeUsernameProblemLanguageResultExecution timeMemory
524896AmrTrampoline (info1cup20_trampoline)C++14
0 / 100
2073 ms406176 KiB
/* 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; }

Compilation message (stderr)

trampoline.cpp: In function 'bool isvalid(ll, ll)':
trampoline.cpp:24:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   24 |     if(x>=n||y>=m||vis[x][y]) return 0; return 1;
      |     ^~
trampoline.cpp:24:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   24 |     if(x>=n||y>=m||vis[x][y]) return 0; return 1;
      |                                         ^~~~~~
#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...