제출 #528238

#제출 시각아이디문제언어결과실행 시간메모리
528238Leo121Traffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include "traffic.h" #include <bits/stdc++.h> #define forn(i, a, b) for(int i = int(a); i <= int(b); ++i) #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const int lim = 1e6; vi graph[lim]; int pesos[lim]; bool visitado[lim]; ll mayor = LLONG_MAX, res = 0; ll pesosub[lim]; int padre[lim]; ll dfs(int u){ pesosub[u] = (ll) pesos[u]; for(int v : graph[u]){ if(!visitados[v]){ padre[v] = u; visitados[v] = 1; pesosub[u] += dfs(v); } } return pesosub; } int LocateCentre(int N, int pp[], int S[], int D[]) { ll pesototal = 0; forn(i, 0, N - 1){ pesos[i] = pp[i]; pesototal += (ll) pp[i]; visitado[i] = 0; pesosub[i] = 0; } forn(i, 0, N - 2){ graph[S[i]].pb(D[i]); graph[D[i]].pb(S[i]); } visitado[0] = 1; padre[0] = 0; dfs(0); ll minimo = INT_MAX, aux = 0, sumaaux; int res = 0; for(int i : graph[0]){ aux = max(aux, pesosub[i]); } minimo = aux; forn(i, 1, N - 1){ aux = 0; for(int j : graph[i]){ if(padre[j] == i){ aux = max(aux, pesosub[j]); } } aux = max(aux, pesototal - pesosub[i]); if(mayor >= aux){ mayor = aux; res = i; } } return res; }

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

traffic.cpp: In function 'll dfs(int)':
traffic.cpp:19:13: error: 'visitados' was not declared in this scope; did you mean 'visitado'?
   19 |         if(!visitados[v]){
      |             ^~~~~~~~~
      |             visitado
traffic.cpp:25:12: error: invalid conversion from 'll*' {aka 'long long int*'} to 'll' {aka 'long long int'} [-fpermissive]
   25 |     return pesosub;
      |            ^~~~~~~
      |            |
      |            ll* {aka long long int*}
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:42:35: warning: unused variable 'sumaaux' [-Wunused-variable]
   42 |     ll minimo = INT_MAX, aux = 0, sumaaux;
      |                                   ^~~~~~~