Submission #1199385

#TimeUsernameProblemLanguageResultExecution timeMemory
1199385Valters07Race (IOI11_race)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "race.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define ld long double
#define en exit(0);
#define pb push_back
#define fi first
#define se second
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 5;
const int K = 1e6 + 5;
const int INF = 1e9 + 5;
vector<pair<int,int> > g[N];
vector<int> vert, vals;
int best[K], sub[N], len[N];
ll dist[N];
int k, res = INF;
bool ban[N];
int get_centroid(int u, int p, int sz)
{
    sub[u] = 1;
    int mx = -1;
    for(auto [v, w] : g[u])
    {
        if(!ban[v] && v != p)
        {
            int t = get_centroid(v, u, sz);
            if(t != -1)
                return t;
            sub[u] += sub[v];
            mx = max(mx, sub[v]);
        }
    }
    mx = max(mx, sz - sub[u]);
    if(mx <= sz / 2)
        return u;
    return -1;
}
void dfs(int u, int p)
{
    for(auto [v, w] : g[u])
    {
        if(!ban[v] && v != p)
        {
            len[v] = len[u] + 1;
            dist[v] = dist[u] + w;
            dfs(v, u);
        }
    }
    vert.pb(u);
}
void go(int u)
{
    int sz = sub[u];
    u = get_centroid(u, u, sz);
    get_centroid(u, u, sz);
    ban[u] = 1;
    for(auto [v, w] : g[u])
    {
        if(!ban[v])
        {
            vert.clear();
            dist[v] = w;
            len[v] = 1;
            dfs(v, v);
            for(auto x : vert)
            {
                ll l = len[x], d = dist[x];
                if(k - d >= 0)
                    res = min(res, l + best[k - d]);
            }
            for(auto x : vert)
            {
                ll l = len[x], d = dist[x];
                if(dist[d] <= k)
                {
                    best[d] = min(best[d], l);
                    vals.pb(d);
                }
            }
        }
    }
    for(auto x : vals)
        best[x] = INF;
    best[0] = 0;
    vals.clear();
    for(auto [v, w] : g[u])
        if(!ban[v])
            go(v);
}
int best_path(int N, int K, int H[][2], int L[])
{
    k = K;
    for(int i = 0;i <= k;i++)
        best[i] = INF;
    best[0] = 0;
    for(int i = 0;i < N - 1;i++)
    {
        int u = H[i][0], v = H[i][1], w = L[i];
        g[u].pb({v, w});
        g[v].pb({u, w});
    }
    sub[0] = N;
    go(0);
    return (res == INF ? -1 : res);
}

Compilation message (stderr)

race.cpp: In function 'void go(int)':
race.cpp:74:30: error: no matching function for call to 'min(int&, long long int)'
   74 |                     res = min(res, l + best[k - d]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from race.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
race.cpp:74:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   74 |                     res = min(res, l + best[k - d]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from race.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
race.cpp:74:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   74 |                     res = min(res, l + best[k - d]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
race.cpp:74:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |                     res = min(res, l + best[k - d]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
race.cpp:74:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |                     res = min(res, l + best[k - d]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~
race.cpp:81:34: error: no matching function for call to 'min(int&, long long int&)'
   81 |                     best[d] = min(best[d], l);
      |                               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from race.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
race.cpp:81:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   81 |                     best[d] = min(best[d], l);
      |                               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from race.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
race.cpp:81:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   81 |                     best[d] = min(best[d], l);
      |                               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
race.cpp:81:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   81 |                     best[d] = min(best[d], l);
      |                               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
race.cpp:81:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   81 |                     best[d] = min(best[d], l);
      |                               ~~~^~~~~~~~~~~~