제출 #1028262

#제출 시각아이디문제언어결과실행 시간메모리
1028262TobTraffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#include "traffic.h" #define F first #define S second #define all(x) x.begin(), x.end() #define pb push_back #define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long ll; typedef pair <ll, ll> pii; const int N = 1e6 + 7; int sum, fo; int a[N], siz[N], res[N]; vector <int> adj[N]; int dfs(int x, bool rev, int p = -1, int d = 0) { if (!rev) { siz[x] = a[x]; for (auto y : adj[x]) if (y != p) siz[x] += dfs(y, 0, x); return siz[x]; } int mx = d, cur = x; for (auto y : adj[x]) if (y != p) mx = max(mx, siz[y]); res[x] = mx; for (auto y : adj[x]) if (y != p) { int z = dfs(y, 1, x, sum-siz[y]); if (res[z] < res[cur]) cur = z; } return cur; } int LocateCentre(int n, int pp[], int S[], int D[]) { for (int i = 0; i < n; i++) { a[i] = pp[i]; sum += a[i]; } for (int i = 0; i < n-1; i++) { adj[S[i]].pb(D[i]); adj[D[i]].pb(S[i]); } dfs(0, 0); return dfs(0, 1); } //----------------------------------------- static int NN,PP[1000000],SS[1000000],DD[1000000]; int main(){ int i; scanf("%d",&NN); for (i=0;i<NN;i++) scanf("%d",&PP[i]); for (i=0;i<NN-1;i++) scanf("%d%d",&SS[i],&DD[i]); int r = LocateCentre(NN,PP,SS,DD); printf("%d\n",r); return 0; }

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

traffic.cpp: In function 'int main()':
traffic.cpp:57:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |  scanf("%d",&NN);
      |  ~~~~~^~~~~~~~~~
traffic.cpp:58:26: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |  for (i=0;i<NN;i++) scanf("%d",&PP[i]);
      |                     ~~~~~^~~~~~~~~~~~~
traffic.cpp:59:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |  for (i=0;i<NN-1;i++) scanf("%d%d",&SS[i],&DD[i]);
      |                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccDJpQAz.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc1hEeEy.o:traffic.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status