Submission #878962

#TimeUsernameProblemLanguageResultExecution timeMemory
878962sabukatsireTraffic (IOI10_traffic)C++17
0 / 100
8 ms31068 KiB
#include<bits/stdc++.h> using namespace std; #include "traffic.h" vector<int> v[1000001]; int sz[1000001],ans = 200000000000,idx; void dfs(int curr,int pp,int sum){ int mx = 0; for(int j=0;j<v[curr].size();j++){ if(v[curr][j] == pp) continue; dfs(v[curr][j],curr,sum); 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]){ int sum = 0; for(int i=0;i<n;i++) v[i].clear(); 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,sum); return idx; }

Compilation message (stderr)

traffic.cpp:5:23: warning: overflow in conversion from 'long int' to 'int' changes value from '200000000000' to '-1863462912' [-Woverflow]
    5 | int sz[1000001],ans = 200000000000,idx;
      |                       ^~~~~~~~~~~~
traffic.cpp: In function 'void dfs(int, int, int)':
traffic.cpp:8:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  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...