Submission #448573

#TimeUsernameProblemLanguageResultExecution timeMemory
448573DeepessonTraffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define MAX 1210000 typedef std::pair<long long,long long> pii; std::vector<long long> con[MAX]; long long res = 2e9+10; long long ind; int* pop; long long dfs(long long pos,long long prev,long long dist){ long long max = dist; long long soma = pop[pos]; for(auto&x:con[pos]){ if(x!=prev){ long long r = dfs(x,pos,dist+(long long)pop[pos]); max=std::max(max,r); soma+=r; } } if(max<res){ res=std::min(res,max); ind=pos; } return soma; } int LocateCentre(int N, int pp[], int S[], int D[]) { pop=pp; for(auto&x:con)x.clear(); res=2e9+10; for(int i=0;i!=N-1;++i){ con[S[i]].push_back(D[i]); con[D[i]].push_back(S[i]); } int start = 0; for(int i=0;i!=N;++i)if(con[i].size()==1)start=i; dfs(start,-1,0); return ind; } static int N,P[1000000],S[1000000],D[1000000]; int main(){ int i; scanf("%d",&N); for (i=0;i<N;i++) scanf("%d",&P[i]); for (i=0;i<N-1;i++) scanf("%d%d",&S[i],&D[i]); int r = LocateCentre(N,P,S,D); printf("%d\n",r); return 0; }

Compilation message (stderr)

traffic.cpp: In function 'int main()':
traffic.cpp:42:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |    scanf("%d",&N);
      |    ~~~~~^~~~~~~~~
traffic.cpp:43:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |    for (i=0;i<N;i++) scanf("%d",&P[i]);
      |                      ~~~~~^~~~~~~~~~~~
traffic.cpp:44:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |    for (i=0;i<N-1;i++) scanf("%d%d",&S[i],&D[i]);
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccSH8wSG.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccDpGqiJ.o:traffic.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status