結果

問題 No.2195 AND Set
ユーザー 👑 Nachia
提出日時 2023-01-20 21:50:12
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 2,508 ms
コンパイル使用メモリ 120,920 KB
最終ジャッジ日時 2025-02-10 04:45:36
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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