Submission #212168

# Submission time Handle Problem Language Result Execution time Memory
212168 2020-03-22T12:03:22 Z DodgeBallMan Amusement Park (JOI17_amusement_park) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second

using namespace std;

const int N = 1e4 + 10;
vector<pii> t[N], e, tre, init;
vector<int> g[N];
int par[N], id[N], re[N], deg[N], idx, n, m;

void dfs( int u, int p ) { re[u] = id[u] = idx++; for( int v : g[u] ) if( v != p ) dfs( v, u ); }

void extend_tree( int u, int p ) {
    if( !t[u].empty() ) return;
    int leaf;
    vector<pii> tree = t[p];
    for( pii e : tree ) ++deg[e.x], ++deg[e.y];
    for( pii e : tree ) {
        int a, b; tie( a, b ) = e;
        if( deg[a] == 1 && a != p ) { leaf = a; break; }
        if( deg[b] == 1 && b != p ) { leaf = b; break; }
    }
    re[u] = re[leaf];
    for( pii e : tree ) {
        --deg[e.x], --deg[e.y];
        if( e.x == leaf || e.y == leaf ) continue;
        t[u].emplace_back( e );
    }
    t[u].emplace_back( u, p );
    for( int v : g[u] ) if( v != p ) extend_tree( v, u );
}

void Joi( int N, int M, int A[], int B[], long long X, int t ) {
    n = N, m = M;
    iota( par, par + N, 0 );
    for( int i = 0 ; i < m ; i++ ) e.emplace_back( pii( A[i], B[i] ) );
    for( pii x : e ) {
        int a = find( x.x ), b = find( x.y );
        if( a != b ) {
            par[a] = b;
            g[x.x].emplace_back( x.y );
            tre.emplace_back( x );
        }
    }
    dfs( 0, 0 );
    for( pii e : tre ) if( id[e.x] < 60 && id[e.y] < 60 ) init.emplace_back( e );
    for( int i = 0 ; i < n ; i++ ) if( id[i] < 60 ) {
        re[i] = id[i];
        t[i] = init;
    }
    for( int i = 0 ; i < n ; i++ ) if( id[i] < 60 ) for( int v : g[i] ) extend_tree( v, i );
    for( int i = 0 ; i < n ; i++ ) MessageBoard( i, X >> re[i] & 1 );
}
#include <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second

using namespace std;

const int N = 1e4 + 10;
vector<pii> t[N], e, tre, init;
vector<int> g[N];
int par[N], id[N], re[N], deg[N], idx, n, m;

void dfs( int u, int p ) { re[u] = id[u] = idx++; for( int v : g[u] ) if( v != p ) dfs( v, u ); }

void extend_tree( int u, int p ) {
    if( !t[u].empty() ) return;
    int leaf;
    vector<pii> tree = t[p];
    for( pii e : tree ) ++deg[e.x], ++deg[e.y];
    for( pii e : tree ) {
        int a, b; tie( a, b ) = e;
        if( deg[a] == 1 && a != p ) { leaf = a; break; }
        if( deg[b] == 1 && b != p ) { leaf = b; break; }
    }
    re[u] = re[leaf];
    for( pii e : tree ) {
        --deg[e.x], --deg[e.y];
        if( e.x == leaf || e.y == leaf ) continue;
        t[u].emplace_back( e );
    }
    t[u].emplace_back( u, p );
    for( int v : g[u] ) if( v != p ) extend_tree( v, u );
}

void get_ans( int u, int p ) {
    for( int v : g[u] ) if( v != p ) {
        int nex = Move( v );
        if( nex ) ans += 1ll << re[v];
        get_ans( v, u );
        Move( u );
    }
}
long long Ioi( int N, int M, int A[], int B[], int P, int V, int t ) {
    n = N, m = M;
    iota( par, par + N, 0 );
    for( int i = 0 ; i < m ; i++ ) e.emplace_back( pii( A[i], B[i] ) );
    for( pii x : e ) {
        int a = find( x.x ), b = find( x.y );
        if( a != b ) {
            par[a] = b;
            g[x.x].emplace_back( x.y );
            tre.emplace_back( x );
        }
    }
    dfs( 0, 0 );
    for( pii e : tre ) if( id[e.x] < 60 && id[e.y] < 60 ) init.emplace_back( e );
    for( int i = 0 ; i < n ; i++ ) if( id[i] < 60 ) {
        re[i] = id[i];
        t[i] = init;
    }
    for( int i = 0 ; i < n ; i++ ) if( id[i] < 60 ) for( int v : g[i] ) extend_tree( v, i );
    for( int i = 0 ; i < n ; i++ ) g[i].clear();
    for( pii e : t[P] ) g[e.x].emplace_back( e.y ), g[e.y].emplace_back( e.x );
    if( V ) ans += 1ll << re[P];
    get_ans( P, P );
    return ans;
}

Compilation message

Joi.cpp: In function 'void Joi(int, int, int*, int*, long long int, int)':
Joi.cpp:40:27: error: no matching function for call to 'find(int&)'
         int a = find( x.x ), b = find( x.y );
                           ^
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 Joi.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:
Joi.cpp:40:27: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
         int a = find( x.x ), b = find( x.y );
                           ^
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 Joi.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:
Joi.cpp:40:27: note:   candidate expects 3 arguments, 1 provided
         int a = find( x.x ), b = find( x.y );
                           ^
Joi.cpp:41:18: error: 'b' was not declared in this scope
         if( a != b ) {
                  ^
Joi.cpp:51:12: error: invalid types 'int[int]' for array subscript
         t[i] = init;
            ^
Joi.cpp:54:36: error: 'MessageBoard' was not declared in this scope
     for( int i = 0 ; i < n ; i++ ) MessageBoard( i, X >> re[i] & 1 );
                                    ^~~~~~~~~~~~

Ioi.cpp: In function 'void get_ans(int, int)':
Ioi.cpp:37:19: error: 'Move' was not declared in this scope
         int nex = Move( v );
                   ^~~~
Ioi.cpp:38:19: error: 'ans' was not declared in this scope
         if( nex ) ans += 1ll << re[v];
                   ^~~
Ioi.cpp:38:19: note: suggested alternative: 'abs'
         if( nex ) ans += 1ll << re[v];
                   ^~~
                   abs
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:48:27: error: no matching function for call to 'find(int&)'
         int a = find( x.x ), b = find( x.y );
                           ^
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 Ioi.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:
Ioi.cpp:48:27: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
         int a = find( x.x ), b = find( x.y );
                           ^
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 Ioi.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:
Ioi.cpp:48:27: note:   candidate expects 3 arguments, 1 provided
         int a = find( x.x ), b = find( x.y );
                           ^
Ioi.cpp:49:18: error: 'b' was not declared in this scope
         if( a != b ) {
                  ^
Ioi.cpp:59:12: error: invalid types 'int[int]' for array subscript
         t[i] = init;
            ^
Ioi.cpp:63:21: error: invalid types 'int[int]' for array subscript
     for( pii e : t[P] ) g[e.x].emplace_back( e.y ), g[e.y].emplace_back( e.x );
                     ^
Ioi.cpp:64:13: error: 'ans' was not declared in this scope
     if( V ) ans += 1ll << re[P];
             ^~~
Ioi.cpp:64:13: note: suggested alternative: 'abs'
     if( V ) ans += 1ll << re[P];
             ^~~
             abs
Ioi.cpp:66:12: error: 'ans' was not declared in this scope
     return ans;
            ^~~
Ioi.cpp:66:12: note: suggested alternative: 'abs'
     return ans;
            ^~~
            abs