Submission #613951

#TimeUsernameProblemLanguageResultExecution timeMemory
613951andrei_boaca007 (CEOI14_007)C++14
0 / 100
219 ms17644 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock().now().time_since_epoch().count()); typedef long long ll; int n,m,s,d,a,b; vector<int> muchii[200005]; int dist[5][200005]; void bfs(int start,int index) { for(int i=1;i<=n;i++) dist[index][i]=1e9; dist[index][start]=0; queue<int> coada; coada.push(start); while(!coada.empty()) { int nod=coada.front(); coada.pop(); for(int i:muchii[nod]) if(dist[index][i]>dist[index][nod]+1) { dist[index][i]=dist[index][nod]+1; coada.push(i); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m>>s>>d>>a>>b; for(int i=1;i<=m;i++) { int x,y; cin>>x>>y; muchii[x].push_back(y); muchii[y].push_back(x); } bfs(a,1); bfs(b,2); bfs(d,3); bfs(s,4); int minim=1e9; for(int i=1;i<=n;i++) { bool good; if(dist[4][i]<=1) good=1; else { good=0; if(dist[1][i]+rng()%2>=dist[1][s]) { if(dist[2][i]+1>=dist[2][s]) good=1; } if(dist[2][i]+rng()%2>=dist[2][s]) { if(dist[1][i]+1>=dist[1][s]) good=1; } } if(!good) minim=min(minim,dist[3][i]-2); } cout<<max(-1,minim); return 0; }

Compilation message (stderr)

007.cpp: In function 'int main()':
007.cpp:53:34: warning: comparison of integer expressions of different signedness: 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |             if(dist[1][i]+rng()%2>=dist[1][s])
      |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
007.cpp:58:34: warning: comparison of integer expressions of different signedness: 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |             if(dist[2][i]+rng()%2>=dist[2][s])
      |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...