Submission #229064

#TimeUsernameProblemLanguageResultExecution timeMemory
229064DodgeBallManWerewolf (IOI18_werewolf)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; struct qq { int s, e, l, r, id; int mx, mn; qq( int s, int e, int l, int r, int id ) : s(s), e(e), l(l), r(r), id(id) {} }; bool cmpl( qq a, qq b ) { return a.l < b.l; } bool cmpr( qq a, qq b ) { return a.r < b.r; } int n, par[2*N], va[2*N], m, q; set<int> roots[2*N]; vector<qq> want[2*N], que; vector<int> ans, tmin[2*N], tmax[2*N], g[2*N]; int findroot( int now ) { if( par[now] == now ) return now; else return par[now] = find( par[now] ); } void pre( int u = 2*n-2 ) { if( u < n ) pred.emplace_back( u ); for( int v : tmin ) dfs( v ); } void dfs( int u = 2*n-2 ) { lb[u] = 1e9, rb[u] = -1; if( u < n ) lb[u] = rb[u] = va[u]; for( int v : tmin ) { dfs( v ); lb[u] = min( lb[u], lb[v] ), rb[u] = max( rb[u], rb[v] ); } } void solve( int u = n*2-2 ) { if( u < n ) roots[u].insert( va[u] ); pii hv( 0, -1 ); for( int v : tmax[u] ) hv = max( hv, pii( roots[v].size(), v ) ); if( hv.y != -1 ) { swap( roots[hv.y], roots[u] ); for( int v : tmax[u] ) { for( int x : s[v] ) s[u].insert( x ); } } for( qq i : want[u] ) ans[i.id] = roots[u].upper_bound( rb[i.mn] ) != roots[u].upper_bound( lb[i.mn] - 1 ); } vector<int> check_validity( int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R ) { n = N, m = X.size(), q = S.size(); for( int i = 0 ; i < q ; i++ ) que.emplace_back( qq( S[i], E[i], L[i], R[i], i ) ); for( int i = 0 ; i < m ; i++ ) g[X[i]].emplace_back( Y[i] ), g[Y[i]].emplace_back( X[i] ); for( int i = 1 ; i <= 2*n ; i++ ) par[i] = i; sort( que.begin(), que.end(), cmpr ); int cnt = n, pos = 0; for( int i = 0 ; i < n ; i++ ) { for( int v : g[i] ) { if( v < i ) { int a = findroot( i ), b = findroot( v ); if( a == b ) continue; par[a] = par[b] = ++cnt; tmin[cnt].emplace_back( a ), tmin[cnt].emplace_back( b ); } } while( pos < q && que[pos].r == i ) { que[pos].mn = findroot( que[pos].e ); pos++; } } for( int i = 1 ; i <= 2*n ; i++ ) par[i] = i; sort( que.begin(), que.end(), cmpl ); reverse( que.begin(), que.end() ); cnt = n, pos = 0; for( int i = n-1 ; i >= 0 ; i++ ) { for( int v : g[i] ) { if( v > i ) { int a = findroot( i ), b = findroot( v ); if( a == b ) continue; par[a] = par[b] = ++cnt; tmax[cnt].emplace_back( a ), tmax[cnt].emplace_back( b ); } } while( pos < q && que[pos].l == i ) { que[pos].mx = findroot( que[pos].s ); pos++; } } pre(); for( int i = 0 ; i < n ; i++ ) va[pred[i]] = i; dfs(); ans.resize( q ); for( int i = 0 ; i < q ; i++ ) want[que[i].mx].emplace_back( que[i] ); solve(); } /*int main() { return 0; }*/

Compilation message (stderr)

werewolf.cpp: In function 'int findroot(int)':
werewolf.cpp:23:43: error: no matching function for call to 'find(int&)'
     else return par[now] = find( par[now] );
                                           ^
In file included from /usr/include/c++/7/bits/locale_facets.h:48:0,
                 from /usr/include/c++/7/bits/basic_ios.h:37,
                 from /usr/include/c++/7/ios:44,
                 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 werewolf.cpp:1:
/usr/include/c++/7/bits/streambuf_iterator.h:369:5: note: candidate: template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)
     find(istreambuf_iterator<_CharT> __first,
     ^~~~
/usr/include/c++/7/bits/streambuf_iterator.h:369:5: note:   template argument deduction/substitution failed:
werewolf.cpp:23:43: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
     else return par[now] = find( par[now] );
                                           ^
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 werewolf.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3899:5: note: candidate: template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)
     find(_InputIterator __first, _InputIterator __last,
     ^~~~
/usr/include/c++/7/bits/stl_algo.h:3899:5: note:   template argument deduction/substitution failed:
werewolf.cpp:23:43: note:   candidate expects 3 arguments, 1 provided
     else return par[now] = find( par[now] );
                                           ^
werewolf.cpp: In function 'void pre(int)':
werewolf.cpp:27:17: error: 'pred' was not declared in this scope
     if( u < n ) pred.emplace_back( u );
                 ^~~~
werewolf.cpp:27:17: note: suggested alternative: 'pre'
     if( u < n ) pred.emplace_back( u );
                 ^~~~
                 pre
werewolf.cpp:28:18: error: cannot convert 'std::vector<int>' to 'int' in initialization
     for( int v : tmin ) dfs( v );
                  ^~~~
werewolf.cpp:28:25: error: 'dfs' was not declared in this scope
     for( int v : tmin ) dfs( v );
                         ^~~
werewolf.cpp:28:25: note: suggested alternative: 'ffs'
     for( int v : tmin ) dfs( v );
                         ^~~
                         ffs
werewolf.cpp: In function 'void dfs(int)':
werewolf.cpp:32:5: error: 'lb' was not declared in this scope
     lb[u] = 1e9, rb[u] = -1;
     ^~
werewolf.cpp:32:18: error: 'rb' was not declared in this scope
     lb[u] = 1e9, rb[u] = -1;
                  ^~
werewolf.cpp:34:18: error: cannot convert 'std::vector<int>' to 'int' in initialization
     for( int v : tmin ) {
                  ^~~~
werewolf.cpp: In function 'void solve(int)':
werewolf.cpp:42:5: error: 'pii' was not declared in this scope
     pii hv( 0, -1 );
     ^~~
werewolf.cpp:43:28: error: 'hv' was not declared in this scope
     for( int v : tmax[u] ) hv = max( hv, pii( roots[v].size(), v ) );
                            ^~
werewolf.cpp:43:28: note: suggested alternative: 'v'
     for( int v : tmax[u] ) hv = max( hv, pii( roots[v].size(), v ) );
                            ^~
                            v
werewolf.cpp:44:9: error: 'hv' was not declared in this scope
     if( hv.y != -1 ) {
         ^~
werewolf.cpp:47:26: error: 's' was not declared in this scope
             for( int x : s[v] ) s[u].insert( x );
                          ^
werewolf.cpp:50:61: error: 'rb' was not declared in this scope
     for( qq i : want[u] ) ans[i.id] = roots[u].upper_bound( rb[i.mn] ) != roots[u].upper_bound( lb[i.mn] - 1 );
                                                             ^~
werewolf.cpp:50:97: error: 'lb' was not declared in this scope
     for( qq i : want[u] ) ans[i.id] = roots[u].upper_bound( rb[i.mn] ) != roots[u].upper_bound( lb[i.mn] - 1 );
                                                                                                 ^~
werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:93:39: error: 'pred' was not declared in this scope
     for( int i = 0 ; i < n ; i++ ) va[pred[i]] = i;
                                       ^~~~
werewolf.cpp:93:39: note: suggested alternative: 'pre'
     for( int i = 0 ; i < n ; i++ ) va[pred[i]] = i;
                                       ^~~~
                                       pre
werewolf.cpp:98:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^