Submission #878968

#TimeUsernameProblemLanguageResultExecution timeMemory
878968sabukatsireTraffic (IOI10_traffic)C++17
100 / 100
787 ms166756 KiB
#include<bits/stdc++.h> using namespace std; #include "traffic.h" #pragma GCC target("avx,avx2,fma") vector<int> v[1000001]; int sz[1000001],ans = 2000000000,idx,sum = 0; void dfs(int curr,int pp){ int mx = 0; for(int j=0;j<v[curr].size();j++){ if(v[curr][j] == pp) continue; dfs(v[curr][j],curr); sz[curr] += sz[v[curr][j]]; mx = max(sz[v[curr][j]],mx); } mx = max(mx,sum-sz[curr]); if(ans > mx){ ans = mx; idx = curr; } } int LocateCentre(int n,int p[1000001],int s[1000001],int d[1000001]){ for(int i=0;i<n;i++){ v[s[i]].push_back(d[i]); v[d[i]].push_back(s[i]); sz[i] = p[i]; sum += p[i]; } dfs(0,0); return idx; }

Compilation message (stderr)

traffic.cpp: In function 'void dfs(int, int)':
traffic.cpp:9:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int j=0;j<v[curr].size();j++){
      |              ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...