Submission #373483

#TimeUsernameProblemLanguageResultExecution timeMemory
373483eulerdesojaTraffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; #define int long long #define pb push_back #define sz(x) int(x.size()) typedef pair<int,int>ii; typedef vector<int> vi; void setIO(string s) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } const int mxn=1e6+6; vi g[mxn]; int n,a[mxn],ma[mxn],sum[mxn];//maximum of congestion in a road void dfs(int i,int p){ for(int j:g[i])if(j!=p){ dfs(j,i); sum[i]+=sum[j]; ma[i]=max(ma[i],max(ma[j],sum[j])); } sum[i]+=a[i]; } int32_t main(){ ios_base::sync_with_stdio(0);cin.tie(0); //setIO("sort"); cin>>n; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n-1;i++){ int x,y;cin>>x>>y; g[x].pb(y); g[y].pb(x); } int ans=1e18,res; for(int i=0;i<n;i++){ memset(sum,0,sizeof(sum)); memset(ma,0,sizeof(ma)); dfs(i,-1); if(ma[i]<ans){ ans=ma[i]; res=i; } } cout<<res<<"\n"; return 0; } /* 5 10 10 10 20 20 0 2 1 2 2 3 3 4 */

Compilation message (stderr)

traffic.cpp: In function 'void setIO(std::string)':
traffic.cpp:14:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   freopen((s+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
traffic.cpp:15:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   15 |   freopen((s+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cc4GO54H.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccCYUKNw.o:traffic.cpp:(.text.startup+0x0): first defined here
/tmp/cc4GO54H.o: In function `main':
grader.cpp:(.text.startup+0xd9): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status