Submission #1263845

#TimeUsernameProblemLanguageResultExecution timeMemory
1263845Yelarys경주 (Race) (IOI11_race)C++20
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; //#define int long long typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define pb push_back #define F first #define S second #define mp make_pair #define sz(x)(int) x.size() #define ins insert #define speed ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr) #define rep(i, a, b) for (int i = a; i < b; i++) #define pf push_front #define pb push_back #define all(x) x.begin(), x.end() #define pii pair < int, int > #define pll pair < ll, ll > #define vi vector < int > #define vll vector < long long > #define vpii vector < pair < int, int >> #define vpll vector < pair < long long, long long >> #define mem(x, val) memset(x, val, sizeof x) #define debug cerr << "OK\n"; mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rofl(chrono::steady_clock::now().time_since_epoch().count()); const int inf = 1e9 + 100; const ll INF = (ll)1e18; const ll INF1 = (ll)1e14 + 1; const int MAXN = (int)5e5 + 5; const ll mod = (ll)1e9 + 7; const ll mod1 = (ll)1e9 + 9; const ll MAX = (ll)1e6 + 5; //const int P = 331; //const int K = 17; ll binpow(ll a, ll n) { if (n == 0) return 1; if (n == 1) return (a % mod); ll r = binpow(a, n / 2); if (n & 1) return (((r * r) % mod) * a) % mod; return (r * r) % mod; } void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } ll add(ll a, ll b) { return (((a + b) % mod) + mod) % mod; } ll mul(ll a, ll b) { return (a * b) % mod; } int n, k; map<ll, int> ma[MAXN]; ll sum[MAXN], d[MAXN]; vector<pii> G[MAXN]; vector<int> g[MAXN]; ll ans = INF; void prec(int v, int par = -1) { for (auto [u, w] : G[v]) { if (u == par) continue; g[v].pb(u); sum[u] = sum[v] + w; d[u] = d[v] + 1; prec(u, v); } } void dfs(int v) { for (int u : g[v]) { dfs(u); } ma[v][sum[v]] = d[v]; for (int i = 1; i < sz(g[v]); i++) { int x = g[v][i - 1], y = g[v][i]; if (sz(ma[x]) > sz(ma[y])) swap(ma[x], ma[y]); for (auto [sx, dx] : ma[x]) { ll sy = k + 2 * sum[v] - sx; if (ma[y].count(sy)) { int dy = ma[y][sy]; ans = min(ans, dx + dy - 2 * d[v]); } } for (auto [sx, dx] : ma[x]) { if (!ma[y].count(sx)) { ma[y][sx] = dx; continue; } ma[y][sx] = min(ma[y][sx], dx); } } if (sz(g[v])) { int y = g[v].back(); ll sy = k + sum[v]; if (ma[y].count(sy)) { int dy = ma[y][sy]; ans = min(ans, dy - d[v]); } swap(ma[v], ma[y]); if (!ma[v].count(sum[v])) { ma[v][sum[v]] = d[v]; } else { ma[v][sum[v]] = min(ma[v][sum[v]], d[v]); } } } int best_path(int N, int K, int H[][2], int L[]) { n = N, k = K; for (int i = 0; i < N - 1; i++) { G[H[i][0]].pb({H[i][1], L[i]}); G[H[i][1]].pb({H[i][0], L[i]}); } prec(0); dfs(0); return ans; } //int main() { // //int H[3][2] = {{0, 1}, {1, 2}, {1, 3}}; //int L[3] = {1, 2, 4}; //cout << best_path(4, 3, H, L); //}

Compilation message (stderr)

race.cpp: In function 'void dfs(int)':
race.cpp:114:32: error: no matching function for call to 'min(std::map<long long int, int>::mapped_type&, ll&)'
  114 |             ma[v][sum[v]] = min(ma[v][sum[v]], d[v]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~
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:2:
/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:114:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  114 |             ma[v][sum[v]] = min(ma[v][sum[v]], d[v]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~
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:2:
/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:114:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  114 |             ma[v][sum[v]] = min(ma[v][sum[v]], d[v]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~
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:2:
/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:114:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  114 |             ma[v][sum[v]] = min(ma[v][sum[v]], d[v]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~
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:2:
/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:114:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  114 |             ma[v][sum[v]] = min(ma[v][sum[v]], d[v]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~
race.cpp: In function 'void setIO(std::string)':
race.cpp:51:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:52:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~