제출 #432479

#제출 시각아이디문제언어결과실행 시간메모리
432479NghesTraffic (IOI10_traffic)C++14
0 / 100
46 ms48144 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; typedef int64_t ll; #define E '\n' const int N = 1e6; int fans; int f[N+13]; int g[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; } int dp(int u,int p){ int child = 0; for (int i=0 ; i < a[u].size(); ++i){ int v = a[u][i]; if (v == p) continue; child += dp(v,u) + P[v]; maximize(f[u],f[v] + P[v]); } g[u] = fans - child; } 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 = 1e9+19; int res = 0; for (int i=1; i <= n ; ++i) if (minimize(MIN,max(g[i],f[i]))) res = i; return res; }

컴파일 시 표준 에러 (stderr) 메시지

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