Submission #229063

#TimeUsernameProblemLanguageResultExecution timeMemory
229063DodgeBallManWerewolf (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; }

set<int> roots[2*N];
vector<qq> want[2*N], qq;
vector<int> ans, tmin[2*N], tmax[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 = findset( 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 = findset( 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:20:9: error: 'par' was not declared in this scope
     if( par[now] == now ) return now;
         ^~~
werewolf.cpp: At global scope:
werewolf.cpp:24:21: error: 'n' was not declared in this scope
 void pre( int u = 2*n-2 ) {
                     ^
werewolf.cpp: In function 'void pre(int)':
werewolf.cpp:25:13: error: 'n' was not declared in this scope
     if( u < n ) pred.emplace_back( u );
             ^
werewolf.cpp:25:17: error: 'pred' was not declared in this scope
     if( u < n ) pred.emplace_back( u );
                 ^~~~
werewolf.cpp:25:17: note: suggested alternative: 'pre'
     if( u < n ) pred.emplace_back( u );
                 ^~~~
                 pre
werewolf.cpp:26:18: error: cannot convert 'std::vector<int>' to 'int' in initialization
     for( int v : tmin ) dfs( v );
                  ^~~~
werewolf.cpp:26:25: error: 'dfs' was not declared in this scope
     for( int v : tmin ) dfs( v );
                         ^~~
werewolf.cpp:26:25: note: suggested alternative: 'ffs'
     for( int v : tmin ) dfs( v );
                         ^~~
                         ffs
werewolf.cpp: At global scope:
werewolf.cpp:29:21: error: 'n' was not declared in this scope
 void dfs( int u = 2*n-2 ) {
                     ^
werewolf.cpp: In function 'void dfs(int)':
werewolf.cpp:30:5: error: 'lb' was not declared in this scope
     lb[u] = 1e9, rb[u] = -1;
     ^~
werewolf.cpp:30:18: error: 'rb' was not declared in this scope
     lb[u] = 1e9, rb[u] = -1;
                  ^~
werewolf.cpp:31:13: error: 'n' was not declared in this scope
     if( u < n ) lb[u] = rb[u] = va[u];
             ^
werewolf.cpp:31:33: error: 'va' was not declared in this scope
     if( u < n ) lb[u] = rb[u] = va[u];
                                 ^~
werewolf.cpp:32:18: error: cannot convert 'std::vector<int>' to 'int' in initialization
     for( int v : tmin ) {
                  ^~~~
werewolf.cpp: At global scope:
werewolf.cpp:38:21: error: 'n' was not declared in this scope
 void solve( int u = n*2-2 ) {
                     ^
werewolf.cpp: In function 'void solve(int)':
werewolf.cpp:39:13: error: 'n' was not declared in this scope
     if( u < n ) roots[u].insert( va[u] );
             ^
werewolf.cpp:39:34: error: 'va' was not declared in this scope
     if( u < n ) roots[u].insert( va[u] );
                                  ^~
werewolf.cpp:40:5: error: 'pii' was not declared in this scope
     pii hv( 0, -1 );
     ^~~
werewolf.cpp:41:28: error: 'hv' was not declared in this scope
     for( int v : tmax[u] ) hv = max( hv, pii( roots[v].size(), v ) );
                            ^~
werewolf.cpp:41:28: note: suggested alternative: 'v'
     for( int v : tmax[u] ) hv = max( hv, pii( roots[v].size(), v ) );
                            ^~
                            v
werewolf.cpp:42:9: error: 'hv' was not declared in this scope
     if( hv.y != -1 ) {
         ^~
werewolf.cpp:45:26: error: 's' was not declared in this scope
             for( int x : s[v] ) s[u].insert( x );
                          ^
werewolf.cpp:48:13: error: expected ';' before 'i'
     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:48:111: warning: statement has no effect [-Wunused-value]
     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:49:1: error: expected primary-expression before '}' token
 }
 ^
werewolf.cpp:49:1: error: expected ';' before '}' token
werewolf.cpp:49:1: error: expected primary-expression before '}' token
werewolf.cpp:49:1: error: expected ')' before '}' token
werewolf.cpp:49:1: error: expected primary-expression before '}' token
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:52:5: error: 'n' was not declared in this scope
     n = N, m = X.size(), q = S.size();
     ^
werewolf.cpp:52:12: error: 'm' was not declared in this scope
     n = N, m = X.size(), q = S.size();
            ^
werewolf.cpp:52:26: error: 'q' was not declared in this scope
     n = N, m = X.size(), q = S.size();
                          ^
werewolf.cpp:53:36: error: 'que' was not declared in this scope
     for( int i = 0 ; i < q ; i++ ) que.emplace_back( qq( S[i], E[i], L[i], R[i], i ) );
                                    ^~~
werewolf.cpp:53:84: error: no match for call to '(std::vector<qq>) (__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, int&)'
     for( int i = 0 ; i < q ; i++ ) que.emplace_back( qq( S[i], E[i], L[i], R[i], i ) );
                                                                                    ^
werewolf.cpp:54:36: error: 'g' was not declared in this scope
     for( int i = 0 ; i < m ; i++ ) g[x[i]].emplace_back( y[i] ), g[y[i]].emplace_back( x[i] );
                                    ^
werewolf.cpp:54:38: error: 'x' was not declared in this scope
     for( int i = 0 ; i < m ; i++ ) g[x[i]].emplace_back( y[i] ), g[y[i]].emplace_back( x[i] );
                                      ^
werewolf.cpp:54:58: error: 'y' was not declared in this scope
     for( int i = 0 ; i < m ; i++ ) g[x[i]].emplace_back( y[i] ), g[y[i]].emplace_back( x[i] );
                                                          ^
werewolf.cpp:55:39: error: 'par' was not declared in this scope
     for( int i = 1 ; i <= 2*n ; i++ ) par[i] = i;
                                       ^~~
werewolf.cpp:56:11: error: 'que' was not declared in this scope
     sort( que.begin(), que.end(), cmpr );
           ^~~
werewolf.cpp:59:22: error: 'g' was not declared in this scope
         for( int v : g[i] ) {
                      ^
werewolf.cpp:63:17: error: 'par' was not declared in this scope
                 par[a] = par[b] = ++cnt;
                 ^~~
werewolf.cpp:68:21: error: 'findset' was not declared in this scope
       que[pos].mn = findset( que[pos].e );
                     ^~~~~~~
werewolf.cpp:68:21: note: suggested alternative: 'findroot'
       que[pos].mn = findset( que[pos].e );
                     ^~~~~~~
                     findroot
werewolf.cpp:72:39: error: 'par' was not declared in this scope
     for( int i = 1 ; i <= 2*n ; i++ ) par[i] = i;
                                       ^~~
werewolf.cpp:77:22: error: 'g' was not declared in this scope
         for( int v : g[i] ) {
                      ^
werewolf.cpp:81:17: error: 'par' was not declared in this scope
                 par[a] = par[b] = ++cnt;
                 ^~~
werewolf.cpp:86:21: error: 'findset' was not declared in this scope
       que[pos].mx = findset( que[pos].s );
                     ^~~~~~~
werewolf.cpp:86:21: note: suggested alternative: 'findroot'
       que[pos].mx = findset( que[pos].s );
                     ^~~~~~~
                     findroot
werewolf.cpp:91:36: error: 'va' was not declared in this scope
     for( int i = 0 ; i < n ; i++ ) va[pred[i]] = i;
                                    ^~
werewolf.cpp:91:39: error: 'pred' was not declared in this scope
     for( int i = 0 ; i < n ; i++ ) va[pred[i]] = i;
                                       ^~~~
werewolf.cpp:91:39: note: suggested alternative: 'pre'
     for( int i = 0 ; i < n ; i++ ) va[pred[i]] = i;
                                       ^~~~
                                       pre
werewolf.cpp:96:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^