結果
問題 | No.2195 AND Set |
ユーザー | 👑 p-adic |
提出日時 | 2022-11-29 15:07:01 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 465 ms / 2,000 ms |
コード長 | 3,534 bytes |
コンパイル時間 | 3,632 ms |
コンパイル使用メモリ | 233,036 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-11-15 02:49:50 |
合計ジャッジ時間 | 10,067 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 355 ms
6,816 KB |
testcase_03 | AC | 381 ms
6,820 KB |
testcase_04 | AC | 350 ms
6,816 KB |
testcase_05 | AC | 347 ms
6,820 KB |
testcase_06 | AC | 348 ms
6,816 KB |
testcase_07 | AC | 286 ms
6,816 KB |
testcase_08 | AC | 336 ms
6,816 KB |
testcase_09 | AC | 276 ms
6,816 KB |
testcase_10 | AC | 465 ms
9,600 KB |
testcase_11 | AC | 465 ms
9,728 KB |
testcase_12 | AC | 453 ms
9,728 KB |
testcase_13 | AC | 464 ms
9,728 KB |
testcase_14 | AC | 453 ms
9,728 KB |
ソースコード
// 入力フォーマットチェックその2 #pragma GCC optimize ( "O3" ) #pragma GCC target ( "avx" ) #include <bits/stdc++.h> using namespace std; using ll = long long; #define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::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 GETLINE( A ) string A; getline( cin , A ) #define GETLINE_SEPARATE( A , SEPARATOR ) string A; getline( cin , A , SEPARATOR ) #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define FOREQINV( VAR , INITIAL , FINAL ) for( TYPE_OF( INITIAL ) VAR = INITIAL ; VAR >= FINAL ; VAR -- ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) #define QUIT return 0 #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT // 入力フォーマットチェック用 // 余分な改行を許さない // #define CHECK_REDUNDANT_INPUT string VARIABLE_FOR_CHECK_REDUNDANT_INPUT = ""; cin >> VARIABLE_FOR_CHECK_REDUNDANT_INPUT; assert( VARIABLE_FOR_CHECK_REDUNDANT_INPUT == "" ); assert( ! cin ); #define CHECK_REDUNDANT_INPUT string VARIABLE_FOR_CHECK_REDUNDANT_INPUT = ""; getline( cin , VARIABLE_FOR_CHECK_REDUNDANT_INPUT ); assert( VARIABLE_FOR_CHECK_REDUNDANT_INPUT == "" ); assert( ! cin ); // |N| <= BOUNDを満たすNをSから構築 #define STOI( S , N , BOUND ) TYPE_OF( BOUND ) N = 0; { bool VARIABLE_FOR_POSITIVITY_FOR_STOI = true; assert( S != "" ); if( S.substr( 0 , 1 ) == "-" ){ VARIABLE_FOR_POSITIVITY_FOR_STOI = false; S = S.substr( 1 ); assert( S != "" ); } assert( S.substr( 0 , 1 ) != " " ); while( S == "" ? false : S.substr( 0 , 1 ) != " " ){ assert( N < BOUND / 10 ? true : N == BOUND / 10 && stoi( S.substr( 0 , 1 ) ) <= BOUND % 10 ); N = N * 10 + stoi( S.substr( 0 , 1 ) ); S = S.substr( 1 ); } if( ! VARIABLE_FOR_POSITIVITY_FOR_STOI ){ N *= -1; } if( S != "" ){ S = S.substr( 1 ); } } // 1行で入力される変数の個数が適切か確認(半角空白の個数+1を調べる) #define COUNT_VARIABLE( S , VARIABLE_NUMBER ) { int size = S.size(); int count = 0; for( int i = 0 ; i < size ; i++ ){ if( S.substr( i , 1 ) == " " ){ count++; } } assert( count + 1 == VARIABLE_NUMBER ); } int main() { UNTIE; CEXPR( int , bound_Q , 400000 ); GETLINE( Q_str ); COUNT_VARIABLE( Q_str , 1 ); STOI( Q_str , Q , bound_Q ); CEXPR( int , length , 30 ); CEXPR( ll , bound_x , ( ll(1) << 30 ) - 1 ); map<ll,bool> S{}; int A[length] = {}; ll answer; REPEAT( Q ){ GETLINE( query ); STOI( query , num , 3 ); if( num == 1 ){ COUNT_VARIABLE( query , 1 ); STOI( query , x , bound_x ); if( S.count( x ) == 0 ){ S[x] = true; FOR( i , 0 , length ){ if( x % 2 == 0 ){ A[i]++; } x /= 2; } } } else if( num == 2 ){ COUNT_VARIABLE( query , 1 ); STOI( query , x , bound_x ); if( S.count( x ) == 1 ){ S.erase( x ); FOR( i , 0 , length ){ if( x % 2 == 0 ){ A[i]--; } x /= 2; } } } else { answer = 0; FOREQINV( i , length - 1 , 0 ){ answer *= 2; if( A[i] == 0 ){ answer++; } } cout << ( answer == bound_x ? -1 : answer ) << "\n"; } } CHECK_REDUNDANT_INPUT; QUIT; }