(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #206978

#제출 시각아이디문제언어결과실행 시간메모리
206978joylintpTraffic (IOI10_traffic)C++17
100 / 100
1802 ms242100 KiB
#include "traffic.h" #include<bits/stdc++.h> using namespace std; bool vis[1000000]; long long val[1000000], sum; set<int> edge[1000000]; void dfs(int k) { vis[k] = true; for (int i : edge[k]) if (!vis[i]) edge[i].erase(k), dfs(i), val[k] += val[i]; } int LocateCentre(int N, int pp[], int S[], int D[]) { for (int i = 0; i < N; i++) val[i] = pp[i], sum += val[i]; for (int i = 0; i < N - 1; i++) edge[S[i]].insert(D[i]), edge[D[i]].insert(S[i]); dfs(0); int ret; long long mn = 1e18; for (int i = 0; i < N; i++) { long long mx = 0; for (int j : edge[i]) mx = max(mx, val[j]); mx = max(mx, sum - val[i]); if (mx < mn) mn = mx, ret = i; } return ret; }

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

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:37: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...