結果

問題 No.2195 AND Set
ユーザー 👑 NachiaNachia
提出日時 2023-01-20 21:50:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 88,596 KB
実行使用メモリ 8,092 KB
最終ジャッジ日時 2023-09-05 14:06:17
合計ジャッジ時間 4,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 124 ms
4,380 KB
testcase_03 AC 149 ms
4,944 KB
testcase_04 AC 122 ms
4,380 KB
testcase_05 AC 128 ms
4,936 KB
testcase_06 AC 128 ms
4,932 KB
testcase_07 AC 95 ms
4,376 KB
testcase_08 AC 127 ms
4,968 KB
testcase_09 AC 84 ms
4,376 KB
testcase_10 AC 192 ms
8,048 KB
testcase_11 AC 193 ms
8,092 KB
testcase_12 AC 190 ms
8,028 KB
testcase_13 AC 193 ms
8,024 KB
testcase_14 AC 190 ms
8,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <atcoder/modint>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;


int main(){
    int Q; cin >> Q;
    set<int> S;
    vector<int> C(30);
    rep(i,Q){
        int t; cin >> t;
        if(t == 1){
            int x; cin >> x;
            if(S.count(x)) continue;
            S.insert(x);
            rep(j,30) C[j] += 1 - (x >> j & 1);
        }
        if(t == 2){
            int x; cin >> x;
            if(!S.count(x)) continue;
            S.erase(x);
            rep(j,30) C[j] -= 1 - (x >> j & 1);
        }
        if(t == 3){
            if(S.empty()){ cout << "-1\n"; continue; }
            int ans = 0;
            rep(j, 30) ans |= (C[j] ? 0 : 1) << j;
            cout << ans << '\n';
        }
    }
}



struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;

0