Submission #231973

#TimeUsernameProblemLanguageResultExecution timeMemory
231973DodgeBallManTropical Garden (IOI11_garden)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "gardenlib.h" #include "garden.h" using namespace std; const int N = 3e5 + 10; int chk[N], d[N], to[N], cyc; vector<int> vec, g[N]; void dfs( int u ) { chk[u] = 1, vec.emplace_back( u ); int v = g[u][0]; if( !chk[v] ) d[v] = d[u] + 1, dfs( v ); else if( chk[v] == 1 ) for( int i = (int)vec.size() - 1 ; i >= 0 ; i-- ) { cyc++; if( vec[i] == v ) break; } chk[u] = 2, vec.pop_back(); } void count_routes( int n, int m, int p, int r[][2], int q, int G ) { for( int i = 0 ; i < m ; i++ ) { if( g[r[i][0]].size() < 2 ) g[r[i][0]].emplace_back( r[i][1] ); if( g[r[i][1]].size() < 2 ) g[r[i][1]].emplace_back( r[i][0] ); } for( int i = 0 ; i < n ; i++ ) for( int v : g[i] ) { if( g[v][0] == i && g[v].size() > 1 ) { to[i] = v + n; if( g[v].size() == 1 ) to[i+n] = v + n; } else { to[i] = v; if( g[v].size() == 1 ) to[i+n] = v + n; } } for( int i = 0 ; i < 2*n ; i++ ) g[i].clear(); for( int i = 0 ; i < 2*n ; i++ ) g[to[i]].emplace_back( i ); vector<int> ans( q, 0 ); vec.clear(), memset( d, 0, sizeof d ), cyc = 0, memset( chk, 0, sizeof chk ); dfs( p ); for( int i = 0 ; i < q ; i++ ) { for( int j = 0 ; j < n ; j++ ) { if( d[j] > G[i] ) continue ; if( cyc ) ans[i] += ( ( G[i] - d[i] ) % cyc == 0 ); else ans[i] += ( d[i] == len ); } } vec.clear(), memset( d, 0, sizeof d ), cyc = 0, memset( chk, 0, sizeof chk ); dfs( p+n ); for( int i = 0 ; i < q ; i++ ) { for( int j = 0 ; j < n ; j++ ) { if( d[j] > G[i] ) continue ; if( cyc ) ans[i] += ( ( G[i] - d[i] ) % cyc == 0 ); else ans[i] += ( d[i] == len ); } answer( ans[i] ); } }

Compilation message (stderr)

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int)':
garden.cpp:44:27: error: invalid types 'int[int]' for array subscript
             if( d[j] > G[i] ) continue ;
                           ^
garden.cpp:45:40: error: invalid types 'int[int]' for array subscript
             if( cyc ) ans[i] += ( ( G[i] - d[i] ) % cyc == 0 );
                                        ^
garden.cpp:46:38: error: 'len' was not declared in this scope
             else ans[i] += ( d[i] == len );
                                      ^~~
garden.cpp:54:27: error: invalid types 'int[int]' for array subscript
             if( d[j] > G[i] ) continue ;
                           ^
garden.cpp:55:40: error: invalid types 'int[int]' for array subscript
             if( cyc ) ans[i] += ( ( G[i] - d[i] ) % cyc == 0 );
                                        ^
garden.cpp:56:38: error: 'len' was not declared in this scope
             else ans[i] += ( d[i] == len );
                                      ^~~