제출 #377994

#제출 시각아이디문제언어결과실행 시간메모리
377994meperdonas203Traffic (IOI10_traffic)C++17
0 / 100
48 ms48108 KiB
#include "traffic.h" #include <bits/stdc++.h> #include <vector> using namespace std; vector <int> adjacencia[1000002]; int sub_arb[1000002]; int menor=INT_MAX; int ans=0; int dfs(int nodo,int anterior){ for(int i=0;i<adjacencia[nodo].size();i++){ if(adjacencia[nodo][i]!=anterior){ sub_arb[nodo]+=dfs(adjacencia[nodo][i],nodo); } } return sub_arb[nodo]; } void respuesta(int nodo,int anterior){ int maximo=sub_arb[adjacencia[nodo][0]]; int hijo=adjacencia[nodo][0]; for(int i=0;i<adjacencia[nodo].size();i++){ if(sub_arb[adjacencia[nodo][i]]>maximo){ hijo=adjacencia[nodo][i]; maximo=sub_arb[adjacencia[nodo][i]]; } } if(maximo<menor){ ans=nodo; menor=maximo; } if(hijo==anterior){ return ; } sub_arb[nodo]-=sub_arb[hijo]; sub_arb[hijo]+=sub_arb[nodo]; respuesta(hijo,nodo); return; } int LocateCentre(int N, int pp[], int S[], int D[]) { for(int i=0;i<N;i++){ sub_arb[i]=pp[i]; } for(int i= 0;i<=N-2;i++){ adjacencia[S[i]].push_back(D[i]); adjacencia[D[i]].push_back(S[i]); } dfs(0,0); respuesta(0,0); return ans; }

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

traffic.cpp: In function 'int dfs(int, int)':
traffic.cpp:10:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   for(int i=0;i<adjacencia[nodo].size();i++){
      |               ~^~~~~~~~~~~~~~~~~~~~~~~~
traffic.cpp: In function 'void respuesta(int, int)':
traffic.cpp:20:16: 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<adjacencia[nodo].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...