Submission #336119

# Submission time Handle Problem Language Result Execution time Memory
336119 2020-12-14T18:30:33 Z sumit_kk10 Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
vector<pair<long long int, long long int> > graph[N];
bool vis[N];
long long int mx = 0;

void dfs(int source, long long int largest){
    vis[source] = 1;
    mx = max(mx, largest);
    for(auto k : graph[source])
        if(!vis[k.first])
            dfs(k.first, largest + k.second);
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]){
    for(int i = 0; i < M; ++i){
        long long int u = A[i], v = B[i], c = T[i];
        graph[u].push_back({v, c});
        graph[v].push_back({u, c});
        // cout << u << ' ' << v << ' ' << c << endl;
    }
    vector<long long int> diameters;
    for(int i = 0; i < N; ++i){
        if(!vis[i]){
            mx = 0;
            dfs(i, 0);
            cout << mx << '\n';
            diameters.push_back(mx);
        }
    }
    int ans = 0;
    for(auto k : diameters)
        ans = max(ans, k);
    return (ans + (L * (N - M - 1)));
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:38:25: error: no matching function for call to 'max(int&, long long int&)'
   38 |         ans = max(ans, k);
      |                         ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from dreaming.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
dreaming.cpp:38:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   38 |         ans = max(ans, k);
      |                         ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from dreaming.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
dreaming.cpp:38:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   38 |         ans = max(ans, k);
      |                         ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from dreaming.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
dreaming.cpp:38:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |         ans = max(ans, k);
      |                         ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from dreaming.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
dreaming.cpp:38:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |         ans = max(ans, k);
      |                         ^