제출 #383939

#제출 시각아이디문제언어결과실행 시간메모리
383939aaravdodhiaTraffic (IOI10_traffic)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int N; vector<int> P; vector<vector<int>> adj; int DFS(int u, int p, int root){ int max_traffic = 0, cur_traffic = P[u]; for(int v : adj[u]){ if(v == p) continue; max_traffic = max(max_traffic, DFS(v, u, root)); cur_traffic += DFS(v, u, root); } if(u != root){ max_traffic = max(max_traffic, cur_traffic); } return max_traffic; } int LocateCenter(){ int arena = N, min_congestion = 2e9+1; for(int root = 0; root < N; root++){ if(DFS(root, -1, root) < min_congestion){ arena = root; min_congestion = DFS(root, -1, root); } } // cout << min_congestion << endl; return arena; } int main() { cin >> N; adj.resize(N); P.resize(N); for(int i=0; i<N; i++) cin >> P[i]; vector<int> S(N), D(N); for(int i=0; i<N-1; i++) cin >> S[i]; for(int i=0; i<N-1; i++) cin >> D[i]; int a, b; for(int i=0; i<N-1; i++){ adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); } cout << LocateCenter() << endl; }

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

traffic.cpp: In function 'int main()':
traffic.cpp:53:9: warning: unused variable 'a' [-Wunused-variable]
   53 |     int a, b;
      |         ^
traffic.cpp:53:12: warning: unused variable 'b' [-Wunused-variable]
   53 |     int a, b;
      |            ^
/tmp/ccE6CWjm.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccUvnria.o:traffic.cpp:(.text.startup+0x0): first defined here
/tmp/ccE6CWjm.o: In function `main':
grader.cpp:(.text.startup+0xd9): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status