#pragma GCC optimize ( "O3" ) #pragma GCC optimize( "unroll-loops" ) #pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" ) #include using namespace std; using ll = long long; #define MAIN main #define TYPE_OF( VAR ) remove_const::type >::type #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) #define CEXPR( LL , BOUND , VALUE ) constexpr const LL BOUND = VALUE #define CIN( LL , A ) LL A; cin >> A #define ASSERT( A , MIN , MAX ) assert( ( MIN ) <= A && A <= ( MAX ) ) #define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX ) #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT ## HOW_MANY_TIMES , 0 , HOW_MANY_TIMES ) #define QUIT return 0 #define COUT( ANSWER ) cout << ( ANSWER ) << "\n" #define RETURN( ANSWER ) COUT( ANSWER ); QUIT inline CEXPR( int , bound_d , 60 ); int g( ll n ) { constexpr int memory[bound_d] = {0,1,0,2,1,1,2,2,0,1,0,3,1,1,3,3,0,2,0,2,2,2,2,2,0,3,0,3,3,3,3,3,0,2,0,2,2,2,2,2,0,3,0,3,3,3,3,3,0,2,0,2,2,2,2,2,0,3,0,3}; if( n < 60 ){ return memory[n]; } bool found[bound_d] = {}; int d = 0; while( n != 0 ){ if( ( n & 1 ) == 1 ){ found[memory[d]] = true; } d++; n >>= 1; } int gn = 0; while( found[gn] ){ gn++; } return gn; } int MAIN() { UNTIE; CEXPR( int , bound_N , 100000 ); CIN_ASSERT( N , 1 , bound_N ); CEXPR( ll , bound_Ai , 1000000000000000000 ); bool even = true; int grundy = 0; REPEAT( N ){ CIN_ASSERT( Ai , -bound_Ai , bound_Ai ); if( Ai < 0 ){ even = !even; } else { grundy ^= g( Ai ); } } RETURN( ( even && grundy == 0 ) ? 2 : 1 ); }