제출 #383115

#제출 시각아이디문제언어결과실행 시간메모리
383115MastermindTraffic (IOI10_traffic)C++17
25 / 100
5031 ms4716 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; } } return cminind; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...