답안 #544626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544626 2022-04-02T14:02:39 Z pokmui9909 꿈 (IOI13_dreaming) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
ll N, M, L;
vector<pair<ll, ll>> G[100005];
ll V1[100005];
ll D = 0, E = 0;
pair<ll, ll> Dia[100005];
int ans = 0;
pair<ll, ll> path[100005];
void dfs1(ll n, ll p, ll k){
    V1[n] = 1;
    if(D < k){
        D = k;
        E = n;
    }
    for(auto i : G[n]){
        ll nx = i.first, c = i.second;
        if(nx == p) continue;
        dfs1(nx, n, k + c);
    }
}
void dfs2(ll n, ll p, ll d){
    if(n == d) return;
    for(auto i : G[n]){
        ll nx = i.first, c = i.second;
        if(nx == p) continue;
        path[nx] = {n, c};
        dfs2(nx, n, d);
    }
}
ll R[100005];
ll sum = 1e18;
ll cost = 0;
void track(ll n, ll s, ll i){
    if(n == s) return;
    ll nx = path[n].first, c = path[n].second;
    sum = min(sum, max(R[i] - cost, cost));
    cost += c;
    track(nx, s, i);
}
 
int travelTime(int n, int m, int l, int A[], int B[], int T[]){
  	N = n, M = m, L = l;
    for(int i = 0; i < M; i++){
        ll u = A[i], v = B[i], c = T[i];
        u++; v++;
        G[u].push_back({v, c});
        G[v].push_back({u, c});
    }
    fill(R + 1, R + N + 1, -1);
    for(int i = 1; i <= N; i++){
        if(V1[i]) continue;
        D = -1;
        dfs1(i, -1, 0);
        D = -1;
        Dia[i].first = E;
        dfs1(E, -1, 0);
        Dia[i].second = E;
        R[i] = D;
        ans = max(ans, D);
    }
    vector<ll> X;
    for(int i = 1; i <= N; i++){
        if(R[i] == -1) continue;
        dfs2(Dia[i].first, -1, Dia[i].second);
        sum = 1e18, cost = 0;
        track(Dia[i].second, Dia[i].first, i);
        if(Dia[i].first == Dia[i].second) sum = 0;
        X.push_back(sum);
    }
    sort(X.begin(), X.end(), greater<ll>());
    if(X.size() >= 2){
        ans = max(ans, X[0] + X[1] + L);
    }
    if(X.size() >= 3){
        ans = max(ans, X[1] + X[2] + 2 * L);
    }
    return ans;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:62:25: error: no matching function for call to 'max(int&, ll&)'
   62 |         ans = max(ans, D);
      |                         ^
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:1:
/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:62:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   62 |         ans = max(ans, D);
      |                         ^
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:1:
/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:62:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   62 |         ans = max(ans, D);
      |                         ^
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:1:
/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:62:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   62 |         ans = max(ans, D);
      |                         ^
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:1:
/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:62:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   62 |         ans = max(ans, D);
      |                         ^
dreaming.cpp:75:39: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   75 |         ans = max(ans, X[0] + X[1] + L);
      |                                       ^
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:1:
/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:75:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   75 |         ans = max(ans, X[0] + X[1] + L);
      |                                       ^
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:1:
/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:75:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   75 |         ans = max(ans, X[0] + X[1] + L);
      |                                       ^
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:1:
/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:75:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   75 |         ans = max(ans, X[0] + X[1] + L);
      |                                       ^
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:1:
/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:75:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   75 |         ans = max(ans, X[0] + X[1] + L);
      |                                       ^
dreaming.cpp:78:43: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   78 |         ans = max(ans, X[1] + X[2] + 2 * L);
      |                                           ^
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:1:
/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:78:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   78 |         ans = max(ans, X[1] + X[2] + 2 * L);
      |                                           ^
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:1:
/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:78:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   78 |         ans = max(ans, X[1] + X[2] + 2 * L);
      |                                           ^
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:1:
/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:78:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   78 |         ans = max(ans, X[1] + X[2] + 2 * L);
      |                                           ^
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:1:
/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:78:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   78 |         ans = max(ans, X[1] + X[2] + 2 * L);
      |                                           ^