답안 #717000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
717000 2023-03-31T19:55:52 Z HaroldVemeno 꿈 (IOI13_dreaming) C++17
컴파일 오류
0 ms 0 KB
#include "dreaming.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int rd[100000];
bool vis[100000];
struct W {
    int t;
    ll w;
};
vector<vector<W>> al;

void calcrd(int v, int p) {
    vis[v] = true;
    int mrd = 0;
    for(auto a : al[v]) {
        if(a.t == p) continue;
        calcrd(a.t, v);
        mrd = max(mrd, a.w + rd[a.t]);
    }
    rd[v] = mrd;
}

int radius(int v, int p, int tdist) {
    int mrv = -1;
    int mr = tdist;
    int mr2 = tdist;
    for(auto a : al[v]) {
        if(a.t == p) continue;
        if(rd[a.t] + a.w >= mr) {
            mrv = a.t;
            mr2 = mr;
            mr = rd[a.t] + a.w;
        } else if(rd[a.t] + a.w >= mr2) {
            mr2 = rd[a.t] + a.w;
        }
    }
    int br = mr;
    for(auto a : al[v]) {
        if(a.t == p) continue;
        if(a.t == mrv) {
            br = min(br, radius(a.t, v, mr2 + a.w));
        } else {
            br = min(br, radius(a.t, v, mr + a.w));
        }
    }
    return br;
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    al.assign(N, {});
    for(int i = 0; i < M; ++i) {
        al[A[i]].push_back({B[i], T[i]});
        al[B[i]].push_back({A[i], T[i]});
    }
    vector<int> rads;
    for(int i = 0; i < N; ++i) {
        if(vis[i]) continue;
        calcrd(i, i);
        rads.push_back(radius(i, i, 0));
    }
    sort(rbegin(rads), rend(rads));
    if(rads.size() == 1) return rads[0];
    if(rads.size() == 2) return rads[0] + L + rads[1];
    return max(rads[0] + rads[1] + L, rads[1] + 2*L + rads[2]);
}

Compilation message

dreaming.cpp: In function 'void calcrd(int, int)':
dreaming.cpp:21:37: error: no matching function for call to 'max(int&, ll)'
   21 |         mrd = max(mrd, a.w + rd[a.t]);
      |                                     ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
dreaming.cpp:21:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   21 |         mrd = max(mrd, a.w + rd[a.t]);
      |                                     ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
dreaming.cpp:21:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   21 |         mrd = max(mrd, a.w + rd[a.t]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
dreaming.cpp:21:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |         mrd = max(mrd, a.w + rd[a.t]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
dreaming.cpp:21:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |         mrd = max(mrd, a.w + rd[a.t]);
      |                                     ^