제출 #307302

#제출 시각아이디문제언어결과실행 시간메모리
307302zoemberTraffic (IOI10_traffic)C++11
0 / 100
53 ms48248 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int MAXN = 1e6, MAXN2 = 2e9; int total = 0, ans = MAXN2; vector<int> adj[MAXN]; int dfs(int vertex, int parent, int p[]) { int cnt = 0, maxcon = 0; for(int next: adj[vertex]) { if(next != parent) { int curr = dfs(next, vertex, p); maxcon = max(maxcon, curr); cnt += curr; } } maxcon = max(maxcon, total-p[vertex]-maxcon); ans = min(ans, maxcon); cnt += p[vertex]; return cnt; } int LocateCentre(int n, int p[], int s[], int d[]) { for(int i=0; i<(n-1); i++) { adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } for(int i=0; i<n; i++) { total += p[i]; } dfs(0, -1, p); cout << ans << endl; } //int main() { //// freopen("hayfeast.in", "r", stdin); //// freopen("hayfeast.out", "w", stdout); // ios_base::sync_with_stdio(false); // cin.tie(NULL); cout.tie(NULL); // int n; // cin >> n; // int p[n] = {0}, s[n] = {0}, d[n] = {0}; // for(int i=0; i<n; i++) { // cin >> p[i]; // } // for(int i=0; i<(n-1); i++) { // cin >> s[i]; // } // for(int i=0; i<(n-1); i++) { // cin >> d[i]; // } // LocateCentre(n, p, s, d); //}

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

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