Submission #373494

#TimeUsernameProblemLanguageResultExecution timeMemory
373494eulerdesojaTraffic (IOI10_traffic)C++14
0 / 100
23 ms31596 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; #define ll long long #define pb push_back #define sz(x) int(x.size()) typedef pair<int,int>ii; typedef vector<int> vi; const int mxn=1e6+6; //maximum of congestion in a road vi g[mxn]; int ma[mxn],sum[mxn]; bool cmp(ii a,ii b){ if(a.first==b.first)return a.second<b.second; return a.first>b.first; } void dfs(int i,int p,int a[]){ for(int j:g[i])if(j!=p){ dfs(j,i,a); sum[i]+=sum[j]; } sum[i]+=a[i]; } int LocateCentre(int n,int a[],int s[],int d[]){ for(int i=0;i<n-1;i++){ g[s[i]].pb(d[i]); g[d[i]].pb(s[i]); } int ans=2e9+10,res=0; for(int i=0;i<n;i++){ memset(sum,0,sizeof(sum)); memset(ma,0,sizeof(ma)); dfs(i,-1,a); for(int i=0;i<n;i++){ for(int j:g[i])ma[i]=max(ma[i],sum[j]); ma[i]=max(ma[i],sum[0]-sum[i]); } int ans=2e9+10,res=0; if(ma[i]<ans){ ans=ma[i]; res=i; } } return res; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:42:18: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   42 |   int ans=2e9+10,res=0;
      |                  ^~~
traffic.cpp:33:6: warning: unused variable 'ans' [-Wunused-variable]
   33 |  int ans=2e9+10,res=0;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...