제출 #487123

#제출 시각아이디문제언어결과실행 시간메모리
487123Spade1Traffic (IOI10_traffic)C++17
0 / 100
12 ms23804 KiB
#include <bits/stdc++.h> //#include "traffic.h" #define ll long long #define pii pair<int, int> #define st first #define nd second #define pb push_back using namespace std; const int maxN = 1e6 + 10; vector<int> adj[maxN]; int prt[maxN], dis[maxN]; int dfs(int i, int p) { for (auto j : adj[i]) { if (j == p) continue; dis[i] += dfs(j, i); prt[j] = i; } return dis[i]; } int LocateCentre(int N, int P[], int S[], int D[]) { for (int i = 0; i < N - 1; ++i) { adj[S[i]].pb(D[i]); adj[D[i]].pb(S[i]); } dfs(0, -1); int ans = 2e9, c; for (int i = 0; i < N; ++i) { int tmp = 0; for (auto j : adj[i]) { if (j == prt[i]) { tmp = max(tmp, dis[0] - dis[i]); continue; } tmp = max(tmp, dis[j]); } if (tmp < ans) c = i, ans = tmp; } return c; }

컴파일 시 표준 에러 (stderr) 메시지

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:46:12: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |     return c;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...