Submission #383114

#TimeUsernameProblemLanguageResultExecution timeMemory
383114MastermindTraffic (IOI10_traffic)C++17
0 / 100
3 ms516 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; #define pb push_back int LocateCentre(int N, int pp[], int S[], int D[]) { vector<int> adj[N]; for (int i = 0; i < N; i++) { adj[S[i]].pb(D[i]); adj[D[i]].pb(S[i]); } long long cmin = LLONG_MAX; int cminind = 0; for (int i = 0; i < N; i++) { vector<int> dist(N); vector<bool> vis(N); queue<int> q; q.push(i); while (!q.empty()) { int cur = q.front(); q.pop(); vis[cur] = true; for (int next : adj[cur]) { if (!vis[next]) { q.push(next); dist[next] = dist[cur] + 1; } } } long long tot = 0; for (int i = 0; i < N; i++) { tot += pp[i] * dist[i]; } if (tot < cmin) { cmin = tot; cminind = i; } } cout << cminind << endl; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:51:1: warning: no return statement in function returning non-void [-Wreturn-type]
   51 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...