Submission #378262

#TimeUsernameProblemLanguageResultExecution timeMemory
378262BlerarghRace (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define _ <<" "<< #define cerr if(false)cerr /* Test case : 11 12 0 1 3 0 2 4 2 3 5 3 4 4 4 5 6 0 6 3 6 7 2 6 8 5 8 9 6 8 10 7 2 Test case : 4 3 0 1 1 1 2 2 1 3 4 2 */ typedef pair<ll,ll> ii; typedef tuple<ll,ll,ll,ll> tl; //actual dist, tree dist, offset, node const ll MAXN = 2e5+5; const ll INF = 1e18; vector<ii> adjlist[MAXN]; bool visited[MAXN]; multiset<ii> s[MAXN]; int ans=INF, stsize[MAXN], k; void setmerging(ll u, ll dis, ll dep){ visited[u] = 1; stsize[u] = 1; ll maxsize=0, maxid=-1; for (auto v : adjlist[u]){ if (visited[v.first]) continue; setmerging(v.first, dis+v.second, dep+1); stsize[u] += stsize[v.first]; if (stsize[v.first] > maxsize){ maxsize = stsize[v.first]; maxid = v.first; } } cerr << "1Node" _ u _ ": "; for (auto st : s[u]) { cerr << "{" << st.first << "," _ st.second << "}, "; } cerr << '\n'; cerr << maxid _ maxsize _ '\n'; s[u].emplace(dis, dep); if (maxid != -1) s[u].swap(s[maxid]); cerr << "2Node" _ u _ ": "; for (auto st : s[u]) { cerr << "{" << st.first << "," _ st.second << "}, "; } cerr << '\n'; for (auto v : adjlist[u]){ ll node = v.first; for (auto ss : s[node]){ ll actdist = ss.first; ll treedist = ss.second; auto it = s[u].lower_bound(make_pair(k-actdist+2*dis, 0)); if ((*it).first == k - actdist + 2*dis){ ans = min(ans, treedist + (*it).second - 2*dep); cerr << "Found:" _ "{" << ss.first << "," _ ss.second << "}, {" << (*it).first << "," _ (*it).second << "}\n"; } } for (auto ss : s[node]) s[u].emplace(ss); } cerr << "3Node" _ u _ ": "; for (auto st : s[u]) { cerr << "{" << st.first << "," _ st.second << "}, "; } cerr << '\n'; } int best_path(int N, int K, int H[][2], int L[]){ k = K; for (int i=0; i<N-1; i++){ ll a = H[i][0], b = H[i][1], w = L[i]; adjlist[a].emplace_back(b, w); adjlist[b].emplace_back(a, w); } setmerging(0, 0, 0); if (ans == INF) return -1; else return ans; }

Compilation message (stderr)

race.cpp:40:9: warning: overflow in conversion from 'll' {aka 'long long int'} to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   40 | int ans=INF, stsize[MAXN], k;
      |         ^~~
race.cpp: In function 'void setmerging(ll, ll, ll)':
race.cpp:81:63: error: no matching function for call to 'min(int&, ll)'
   81 |                 ans = min(ans, treedist + (*it).second - 2*dep);
      |                                                               ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
race.cpp:81:63: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   81 |                 ans = min(ans, treedist + (*it).second - 2*dep);
      |                                                               ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
race.cpp:81:63: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   81 |                 ans = min(ans, treedist + (*it).second - 2*dep);
      |                                                               ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
race.cpp:81:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   81 |                 ans = min(ans, treedist + (*it).second - 2*dep);
      |                                                               ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
race.cpp:81:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   81 |                 ans = min(ans, treedist + (*it).second - 2*dep);
      |                                                               ^