제출 #335454

#제출 시각아이디문제언어결과실행 시간메모리
335454gozoniteTraffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<pair<int, int>> vii; typedef pair<int, int> pi; vector<int> adj[1000000]; ll p[1000000]; ll sub[1000000]; ll res; ll mt[1000000]; void dfs(int u, int par, ll pc) { ll tsum = 0, mv = 0; for (auto v : adj[u]) { if (v == par) continue; tsum += sub[v]; mv = max(mv, sub[v]); } mt[u] = max(mv, pc); for (auto v : adj[u]) { if (v == par) continue; dfs(v, u, pc+tsum-sub[v]+p[u]); } } ll gsum(int u, int par) { ll tsum = p[u]; for (auto v : adj[u]) { if (v == par) continue; tsum += gsum(v, u); } sub[u] = tsum; return sub[u]; } int LocateCentre(int N, int P[], int S[], int D[]) { for (int i = 0; i < N; i++) adj[i].clear(); for (int i = 0; i < N; i++) p[i] = P[i]; res = 1e18; //fill(mt, mt+N, 0); for (int i = 0; i < N-1; i++) { int a = S[i], b = D[i]; adj[a].push_back(b); adj[b].push_back(a); } gsum(0, -1); dfs(0, -1, 0); //cout << "Debugging array" << endl; //for (int i = 0; i < N; i++) cout << mt[i] << " "; cout << endl; //for (int i = 0; i < N; i++) cout << sub[i] << " "; cout << endl; int mi = 0; for (int i = 1; i < N; i++) { if (mt[i] < mt[mi]) mi = i; } return mi; } int main() { /*int n = 5; int p[] = {10, 10, 10, 20, 20}; int s[] = {0, 0, 0, 3}; int d[] = {1, 2, 3, 4}; cout << LocateCentre(n, p, s, d) << endl;*/ }

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

/tmp/ccsHqcsE.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccZ08ngb.o:traffic.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status