(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #378002

#TimeUsernameProblemLanguageResultExecution timeMemory
378002meperdonas203Traffic (IOI10_traffic)C++17
100 / 100
1093 ms149356 KiB
#include "traffic.h" #include <bits/stdc++.h> #include <vector> using namespace std; vector <int> adjacencia[1000010]; long long int sub_arb[1000010]; long long 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[]) { if(N==1){ return 0; } 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; }

Compilation message (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...