Submission #503248

#TimeUsernameProblemLanguageResultExecution timeMemory
503248Hi_Im_Not_Meo_MeoTraffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000010; int n; int val[MAXN]; vector<int> adj[MAXN]; int vv = INT_MAX, ans; int sz[MAXN]; void comp(int u, int par = -1) { sz[u] = val[u]; for (auto &v : adj[u]) if (v != par) { comp(v, u); sz[u] += sz[v]; } } void dfs(int u, int x = 0, int par = -1) { int mx = x; for (auto &v : adj[u]) if (v != par) { dfs(v, x + sz[u] - sz[v], u); mx = max(mx, sz[v]); } if (mx < vv) { vv = mx; ans = u; } } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", val + i); } for (int i = 0; i < n - 1; i++) { int u, v; scanf("%d%d", &u, &v); adj[u].push_back(v); adj[v].push_back(u); } comp(0); dfs(0); printf("%d\n", ans); }

Compilation message (stderr)

traffic.cpp: In function 'int main()':
traffic.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
traffic.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d", val + i);
      |         ~~~~~^~~~~~~~~~~~~~~
traffic.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%d%d", &u, &v);
      |         ~~~~~^~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccqf6lQ1.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cclJWyu1.o:traffic.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccqf6lQ1.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status