Submission #604161

#TimeUsernameProblemLanguageResultExecution timeMemory
604161PiejanVDCHighway Tolls (IOI18_highway)C++17
Compilation error
0 ms0 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; const int mxN = (int)9e4+5; int def; long long normal; int N_; mt19937 mt(time(nullptr)); long long ask(const std::vector<int> &w); void answer(int s, int t); map<pair<int,int>, int>id; vector<int>re(mxN); int search_point(vector<int>points) { int n = (int)points.size(); int ans = -1; int l = 0, r = n-1; while(l <= r) { if(l == r && ans == -1) { ans = l; break; } int mid = (l+r)/2; vector<int>Ask(N_, 0); for(int i = l ; i <= mid ; i++) Ask[points[i]] = 1; if(ask(Ask) != normal) { r = mid-1; ans = mid; } else l = mid+1; } return points[ans]; } bool present(vector<int>points) { vector<int>Ask(N_, 0); for(auto z : points) Ask[z] = 1; return ask(Ask) != normal; } vector<int>p[mxN]; vector<int>parent(mxN); vector<int>adj[mxN]; int mxDist; int A_ = -2; int h = -2; void dfs(int node, int dist, int e = -1) { if(node == h) return; mxDist = max(mxDist, dist); if(e > -1) p[dist].push_back(id[{node, e}]); parent[node] = e; re[node] = dist; for(auto z : adj[node]) if(z != e) dfs(z, dist+1, node); } int distance() { int l = 1, r = mxDist; int ans = -1; while(l <= r) { int mid = (l+r)/2; if(present(p[mid])) ans = mid, l = mid+1; else r = mid-1; } return ans; } void delete_(int a) { if(a == def) return; for(int i = 0 ; i <= mxDist ; i++) p[i].clear(); stack<int>s; s.push(a); vector<bool>vis(N_+1, 0); vis[a] = 1; while(1) { int node = s.top(); s.pop(); for(auto z : adj[node]) if(!vis[z]) { if(z == def) { h = node; return; } vis[z] = 1; s.push(z); } } } int Check = 1; void check() { /*cout << "Check " << Check++ << '\n';*/ } int num_calls; void find_pair(int n, vector<int>u, vector<int>v, int a_, int b_) { N_ = n-1; vector<int>dummy(n-1, 0); normal = ask(dummy); vector<int>rev(n-1); for(int i = 0 ; i < n-1 ; i++) id[{u[i], v[i]}] = id[{v[i], u[i]}] = i, rev[i] = u[i], adj[u[i]].push_back(v[i]), adj[v[i]].push_back(u[i]); vector<int>d(n); for(int i = 0 ; i < n ; i++) d[i] = i; random_shuffle(d.begin(), d.end(), mt); def = rev[search_point(d)]; dfs(def, 0); int a = distance(); if(a == -1) A_ = def; else { random_shuffle(p[a].begin(), p[a].end(), mt); A_ = search_point(p[a]); A_ = (re[u[A_]] > re[v[A_]] ? u[A_] : v[A_]); } delete_(A_); mxDist = 0; dfs(def, 0); long long need = normal / a_ - max(0, a); int b = need; int B_ = -1; if(b == 0) B_ = def; else { random_shuffle(p[b].begin(), p[b].end(), mt); B_ = search_point(p[b]); B_ = (re[u[B_]] > re[v[B_]] ? u[B_] : v[B_]); } answer(A_, B_); }

Compilation message (stderr)

In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from highway.cpp:2:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::random_shuffle(_RAIter, _RAIter, _Generator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Generator = std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>&]':
highway.cpp:119:40:   required from here
/usr/include/c++/10/bits/stl_algo.h:4636:48: error: no match for call to '(std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>) (__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
 4636 |    _RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/random:49,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:108,
                 from highway.cpp:2:
/usr/include/c++/10/bits/random.h:563:7: note: candidate: 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::operator()() [with _UIntType = long unsigned int; long unsigned int __w = 32; long unsigned int __n = 624; long unsigned int __m = 397; long unsigned int __r = 31; _UIntType __a = 2567483615; long unsigned int __u = 11; _UIntType __d = 4294967295; long unsigned int __s = 7; _UIntType __b = 2636928640; long unsigned int __t = 15; _UIntType __c = 4022730752; long unsigned int __l = 18; _UIntType __f = 1812433253; std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type = long unsigned int]'
  563 |       operator()();
      |       ^~~~~~~~
/usr/include/c++/10/bits/random.h:563:7: note:   candidate expects 0 arguments, 1 provided