Submission #116202

#TimeUsernameProblemLanguageResultExecution timeMemory
116202claudyHighway Tolls (IOI18_highway)C++14
Compilation error
0 ms0 KiB
# pragma GCC optimize("Ofast") # pragma GCC optimization ("unroll-loops") # include "bits/stdc++.h" std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}}; # define ll long long # define clock (clock() * 1000.0 / CLOCKS_PER_SEC) # define rc(s) return cout << s,0 # define rcg(s) cout << s;exit(0) # define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); # define db(x) cerr << #x << " = " << x << '\n' # define pb push_back # define mp make_pair # define all(s) s.begin(),s.end() # define sz(x) (int)((x).size()) //# define int ll using namespace std; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # define LOCAL # define sim template < class c # define ris return * this # define dor > debug & operator << # define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c&) { ris; } #endif }; #define show(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " int gcd(int a, int b) { if(b) return gcd(b,a%b); return a; }mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ long long ask(const std::vector<int> &w); void answer(int s, int t); # define int ll vector<int32_t>askvec; int dist; vector<pair<int,int>>vec[1 << 18]; vector<int>euler; int M,N; vector<int>f; int viz[1 << 18]; void root(int nod) { queue<int>Q; Q.push(nod); euler.clear(); for(int i = 0;i < M;i++) askvec[i] = 0; for(int i = 0;i < N;i++) viz[i] = 0; viz[nod] = 1; f[nod] = -1; while(sz(Q)) { int x = Q.front(); Q.pop(); euler.pb(x); for(auto it : vec[x]) { if(!viz[it.first]) { f[it.first] = it.second; askvec[it.second] = 1; Q.push(it.first); viz[it.first] = 1; } } } for(int i = 0;i < M;i++) askvec[i] = !askvec[i]; } int bs() { int l = 0; int r = N - 1; while(l < r) { int mid = l + r + 1 >> 1; mid += rng() % (min(10,r - mid + 1)); mid = min(mid,r); for(int i = mid;i < N;i++) { if(f[euler[i]] != -1) askvec[f[euler[i]]] = 1; } if(ask(askvec) != dist) l = mid; else r = mid - 1; for(int i = mid;i < N;i++) { if(f[euler[i]] != -1) askvec[f[euler[i]]] = 0; } } return euler[l]; } #undef int void find_pair(int n, vector<int> U, vector<int> V, int A, int B) { #define int ll N = n; M = sz(U); f.resize(N); for(int i = 0;i < sz(U);i++) { vec[U[i]].pb(mp(V[i],i)); vec[V[i]].pb(mp(U[i],i)); } askvec.resize(M); for(int i = 0;i < M;i++) askvec[i] = 0; dist = ask(askvec); int l = 0; int r = N - 1; while(l < r) { int mid = (l + r >> 1); for(int i = 0;i < M;i++) askvec[i] = 0; for(int i = 0;i <= mid;i++) { for(auto it : vec[i]) { askvec[it.second] = 1; } } if(ask(askvec) != dist) r = mid; else l = mid + 1; } root(l); int X = bs(); root(X); int Y = bs(); answer(X,Y); } /* int32_t main(){_ //freopen("input","r",stdin); return 0; }*/

Compilation message (stderr)

highway.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 # pragma GCC optimization ("unroll-loops")
 
highway.cpp: In function 'long long int bs()':
highway.cpp:102:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l + r + 1 >> 1;
             ~~~~~~^~~
highway.cpp:103:37: error: no matching function for call to 'min(int, long long int)'
   mid += rng() % (min(10,r - mid + 1));
                                     ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from highway.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
highway.cpp:103:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   mid += rng() % (min(10,r - mid + 1));
                                     ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from highway.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
highway.cpp:103:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   mid += rng() % (min(10,r - mid + 1));
                                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from highway.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
highway.cpp:103:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   mid += rng() % (min(10,r - mid + 1));
                                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from highway.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
highway.cpp:103:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   mid += rng() % (min(10,r - mid + 1));
                                     ^
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:137:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = (l + r >> 1);
              ~~^~~