Submission #727492

#TimeUsernameProblemLanguageResultExecution timeMemory
727492n0sk1ll007 (CEOI14_007)C++17
0 / 100
596 ms33372 KiB
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0) #define mp make_pair #define xx first #define yy second #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define all(x) x.begin(),x.end() #define ff(i,a,b) for (int i = a; i < b; i++) #define fff(i,a,b) for (int i = a; i <= b; i++) #define bff(i,a,b) for (int i = b-1; i >= a; i--) #define bfff(i,a,b) for (int i = b; i >= a; i--) using namespace std; long double typedef ld; unsigned int typedef ui; long long int typedef li; pair<int,int> typedef pii; pair<li,li> typedef pli; pair<ld,ld> typedef pld; vector<vector<int>> typedef graph; unsigned long long int typedef ull; //const int mod = 998244353; const int mod = 1000000007; //Note to self: Check for overflow graph g(200005); bool vis[200005]; vector<int> njeni[200005],njegovi[200005]; bool moze(int n, int ona, int on, int a, int b, int wait) { fff(i,1,n) vis[i]=false; queue<pii> bfs; bfs.push({on,wait}); while (!bfs.empty()) { auto [p,d]=bfs.front(); bfs.pop(); if (vis[p]) continue; vis[p]=true; //cout<<p<<" "; if (d==0) continue; for (auto it : g[p]) bfs.push({it,d-1}); } if (vis[a]) return false; if (vis[b]) return false; ff(i,0,n) njeni[i].clear(),njegovi[i].clear(); fff(i,1,n) if (vis[i]) njegovi[0].pb(i); njeni[0].pb(ona); fff(i,1,n) vis[i]=false; ff(dubina,0,n) { for (auto p : njeni[dubina]) { if (vis[p]) continue; vis[p]=1; for (auto it : g[p]) njeni[dubina+1].pb(it); } for (auto p : njegovi[dubina]) { if (vis[p]) continue; vis[p]=1; if (p==a) return false; if (p==b) return false; for (auto it : g[p]) njegovi[dubina+1].pb(it); } } return true; } int main() { FAST; int n,m; cin>>n>>m; int ona,on,a,b; cin>>ona>>on>>a>>b; while (m--) { int u,v; cin>>u>>v; g[u].pb(v),g[v].pb(u); } int l=-1,r=n; while (r-l>1) { int mid=(l+r)/2; if (moze(n,ona,on,a,b,mid)) l=mid; else r=mid; } cout<<l<<"\n"; } //Note to self: Check for overflow

Compilation message (stderr)

007.cpp: In function 'bool moze(int, int, int, int, int, int)':
007.cpp:51:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   51 |         if (vis[p]) continue; vis[p]=true; //cout<<p<<" ";
      |         ^~
007.cpp:51:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   51 |         if (vis[p]) continue; vis[p]=true; //cout<<p<<" ";
      |                               ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...