제출 #1266033

#제출 시각아이디문제언어결과실행 시간메모리
1266033cordeiroaloneDreaming (IOI13_dreaming)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "dreaming.h" using namespace std; #define MAX 100005 using ll = long long; vector<pair<ll,int>> listaadj[MAX]; bool calculado[MAX]; vector<ll> centros; int filhos[MAX]; ll distancias[MAX]; ll distlegal[MAX][2]; vector<int> arvoreatual; void contaarvore(int x,int pai){ arvoreatual.push_back(x); calculado[x] = 1; for(auto v : listaadj[x]){ if(v.second == pai) continue; contaarvore(v.second,x); } } void dfs(int x,int pai,int modo){ for(auto v : listaadj[x]){ if(v.second == pai) continue; distlegal[v.second][modo] = distlegal[x][modo] + v.first; dfs(v.second,x,modo); } } void calcularcentro(int x){ distlegal[x][0] = 0; contaarvore(x,-1); dfs(x,-1,0); ll maiordist = 0,maiorid; for(auto v : arvoreatual){ if(distlegal[v][0] > maiordist){ maiordist = distlegal[v][0]; maiorid = v; } } distlegal[maiorid][0] = 0; dfs(maiorid,-1,0); ll maiordist2 = 0,maiorid2; for(auto v : arvoreatual){ if(distlegal[v][0] > maiordist2){ maiordist2 = distlegal[v][0]; maiorid2 = v; } } distlegal[maiorid2][1] = 0; dfs(maiorid2,-1,1); ll menortotal = INT64_MAX; for(auto v : arvoreatual){ menortotal = min(menortotal,max(distlegal[v][0],distlegal[v][1])); } vector<int> temp; swap(temp,arvoreatual); centros.push_back(menortotal); } int travelTime(int N,int M,int L,int A[],int B[],int T[]){ for(int i = 0; i < M; i++){ int a = A[i],b = B[i],w = T[i]; listaadj[a].push_back({w,b}); listaadj[b].push_back({w,a}); } for(int i = 0; i < N; i++){ if(calculado[i])continue; calcularcentro(i); } sort(centros.begin(),centros.end()); int tamcentros = centros.size(); if(centros.size() == 1){ return(centros[0]); }else if(centros.size == 2){ return(centros[tamcentros - 1] + centros[tamcentros - 2] + L); }else{ return(max(centros[tamcentros - 1] + centros[tamcentros - 2] + L, centros[tamcentros - 2] + centros[tamcentros - 3] + (2 * L))); } }

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

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:77:22: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' (did you forget the '()' ?)
   77 |     }else if(centros.size == 2){
      |              ~~~~~~~~^~~~
      |                          ()
dreaming.cpp:82:1: warning: control reaches end of non-void function [-Wreturn-type]
   82 | }
      | ^