Submission #477286

#TimeUsernameProblemLanguageResultExecution timeMemory
477286TsiannisTraffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define INF 100000000000 typedef long long ll; #define MAXN 1000000 ll P[MAXN],D[MAXN],S[MAXN],pre[MAXN]; ll sum=0; int LocateCentre(ll N,ll P[],ll S[],ll D[]) { ll mn=INF; ll index; for (int i=0;i<N;i++) { ll d=(sum-P[i])/2; if (abs(pre[i]-d-P[i])<mn) { mn=abs(pre[i]-d-P[i]); index=i; } } return index; } int main() { ll N; cin>>N; for (int i=0;i<N;i++) { cin>>P[i]; sum+=P[i]; pre[i]=sum; } for (int i=0;i<N-1;i++) { cin>>S[i]>>D[i]; } cout<<LocateCentre(N,P,S,D)<<endl; return 0; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(ll, ll*, ll*, ll*)':
traffic.cpp:21:12: warning: 'index' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |     return index;
      |            ^~~~~
/usr/bin/ld: /tmp/ccqHhWc9.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccchkW7a.o:traffic.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccqHhWc9.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status