제출 #377737

#제출 시각아이디문제언어결과실행 시간메모리
377737AlexRex0Traffic (IOI10_traffic)C++14
0 / 100
5057 ms24044 KiB
#include "traffic.h" #include <stdio.h> #include <bits/stdc++.h> using namespace std; vector<int> g[1000002]; long long int sub[1000002]; bool visitado[1000002]; int v[1000002]; long long int dfs(int nodo, int padre){ sub[nodo]+= v[nodo]; for(int i = 0 ; i < g[nodo].size(); ++i){ if(g[nodo][i] != padre){ sub[nodo]+= dfs(g[nodo][i], nodo); } } return sub[nodo]; } long long int indRes, indMax = -1, Max, aux, Res; static int N,P[1000000],S[1000000],D[1000000]; int LocateCentre(int N, int pp[], int S[], int D[]) { for(int i = 0; i < N - 1; ++i){ g[S[i]].push_back(D[i]); g[D[i]].push_back(S[i]); v[i] = pp[i]; } v[N - 1] = pp[N - 1]; dfs(0, -1); Max = -1; for(int i = 0; i < g[0].size(); ++i){ if(sub[g[0][i]] > Max){ Max = sub[g[0][i]]; } } Res = Max; while(true){ Max = -1; for(int i = 0; i < g[aux].size(); ++i){ if(sub[g[aux][i]] > Max){ Max = sub[g[aux][i]]; indMax = g[aux][i]; } } if(Max < Res){ indRes = aux; Res = Max; } sub[aux]-= sub[indMax]; sub[indMax]+= sub[aux]; if(indRes == indMax){ break; } aux = indMax; } return indRes; }

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

traffic.cpp: In function 'long long int dfs(int, int)':
traffic.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i = 0 ; i < g[nodo].size(); ++i){
      |                     ~~^~~~~~~~~~~~~~~~
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 0; i < g[0].size(); ++i){
      |                    ~~^~~~~~~~~~~~~
traffic.cpp:37:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int i = 0; i < g[aux].size(); ++i){
      |                        ~~^~~~~~~~~~~~~~~
traffic.cpp: At global scope:
traffic.cpp:19:36: warning: 'D' defined but not used [-Wunused-variable]
   19 | static int N,P[1000000],S[1000000],D[1000000];
      |                                    ^
traffic.cpp:19:25: warning: 'S' defined but not used [-Wunused-variable]
   19 | static int N,P[1000000],S[1000000],D[1000000];
      |                         ^
traffic.cpp:19:14: warning: 'P' defined but not used [-Wunused-variable]
   19 | static int N,P[1000000],S[1000000],D[1000000];
      |              ^
traffic.cpp:19:12: warning: 'N' defined but not used [-Wunused-variable]
   19 | static int N,P[1000000],S[1000000],D[1000000];
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...