Submission #344565

#TimeUsernameProblemLanguageResultExecution timeMemory
344565DavidZ122Traffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; typedef long long ll; #define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define F1R(i,a) FOR(i,1,a) #define ROF(i,a,b) for ( i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define rsz resize #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define f first #define s second #define mp make_pair #define pb push_back void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0); if (sz(name)) { freopen((name+".in").c_str(), "r", stdin); freopen((name+".out").c_str(), "w", stdout); } } bool cmp(const pair<pair<int,int>,int>&a, const pair<pair<int,int>,int> &b) { return a.s>b.s; } bool cmp2(const pair<pair<int,int>,int>&a, const pair<pair<int,int>,int> &b) { return a.f.s>b.f.s; } const int SZ=1e6+1; const int MOD=1e9+7; int fans[SZ]; vi adj[SZ]; ll dfs(int node) { ll ans=fans[node]; trav(x, adj[node]) { ans+=dfs(x); } return ans; } ll solve(int node) { ll m=INT_MAX; trav(x, adj[node]) { m=fmin(m, dfs(x)); } return m; } int main() { FIO; ll n; cin>>n; F0R(i, n) cin>>fans[i]; F0R(i, n-1) { ll a, b; cin>>a>>b; adj[a].pb(b); adj[b].pb(a); } ll ans=0, ansMin=INT_MAX; F0R(i, n) { ll a=solve(i); if(a<ansMin) { ans=i; ansMin=a; } } cout<<ans+1<<endl; }

Compilation message (stderr)

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