제출 #208596

#제출 시각아이디문제언어결과실행 시간메모리
208596DodgeBallManTraffic (IOI10_traffic)C++14
0 / 100
18 ms23800 KiB
#include<bits/stdc++.h> #include "traffic.h" using namespace std; const int N = 1e6 + 10; long long val[N]; vector<int> g[N]; long long dfs( int u, int p ) { for( int v : g[u] ) if( v != p ) val[u] += dfs( v, u ); return val[u]; } int LocateCentre(int n, int pp[], int S[], int D[]) { for ( int i = 0 ; i < n ; i++ ) val[i] = pp[i]; for ( int i = 0 ; i < n - 1 ; i++ ) g[S[i]].emplace_back( D[i] ), g[D[i]].emplace_back( S[i] ); dfs( 0, -1 ); int ret; long long mn = 1e18; for ( int i = 0 ; i < n ; i++ ) { long long mx = val[0] - val[i]; for( int v : g[i] ) mx = max( mx, val[v] ); if( mn > mx ) mn = mx, ret = i; } return ret; }

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

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