Submission #432495

#TimeUsernameProblemLanguageResultExecution timeMemory
432495NghesTraffic (IOI10_traffic)C++14
0 / 100
18 ms23756 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; typedef int64_t ll; #define name "main" #define E '\n' const int N = 1e6; int fans; int f[N+13]; int g[N+13]; int child[N+13]; int P[N+13]; vector<int> a[N+13]; bool maximize(int &x,int y){ return x < y ? x =y ,1 : 0; } bool minimize(int &x,int y){ return x > y ? x =y ,1 : 0; } void dp(int u,int p){ for (int i=0 ; i < a[u].size(); ++i){ int v = a[u][i]; if (v == p) continue; dp(v,u); child[u] += child[v]; maximize(f[u],child[v]); } child[u] += P[u]; g[u] = fans - child[u]; } int LocateCentre (int n, int p[], int d[], int s[]) { for (int i=0 ; i < n; ++i){ fans += p[i]; P[i+1] = p[i]; a[s[i]+1] . push_back(d[i]+1); a[d[i]+1] . push_back(s[i]+1); } dp(1,1); int MIN = 2e9; int res = 0; for (int i=1; i <= n ; ++i) if (minimize(MIN,max(g[i],f[i]))) res = i; return res; }

Compilation message (stderr)

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