結果

問題 No.2195 AND Set
ユーザー i_am_noobi_am_noob
提出日時 2023-02-15 18:52:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 945 bytes
コンパイル時間 2,232 ms
コンパイル使用メモリ 205,564 KB
実行使用メモリ 8,068 KB
最終ジャッジ日時 2023-09-25 03:14:16
合計ジャッジ時間 8,007 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 122 ms
4,380 KB
testcase_03 AC 150 ms
4,856 KB
testcase_04 AC 123 ms
4,380 KB
testcase_05 AC 130 ms
4,932 KB
testcase_06 AC 130 ms
4,864 KB
testcase_07 AC 95 ms
4,380 KB
testcase_08 AC 126 ms
4,960 KB
testcase_09 AC 84 ms
4,376 KB
testcase_10 AC 189 ms
8,068 KB
testcase_11 AC 191 ms
8,044 KB
testcase_12 AC 196 ms
7,968 KB
testcase_13 AC 196 ms
7,964 KB
testcase_14 AC 194 ms
8,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;

#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) ((int)a.size())

int a[49];

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int q; cin >> q;
    set<int> st;
    while(q--){
        int op; cin >> op;
        if(op==1){
            int x; cin >> x;
            if(st.count(x)) continue;
            st.insert(x);
            x=~x;
            for(int i=0; i<30; ++i) a[i]+=x>>i&1;
        }
        else if(op==2){
            int x; cin >> x;
            if(!st.count(x)) continue;
            st.erase(x);
            x=~x;
            for(int i=0; i<30; ++i) a[i]-=x>>i&1;
        }
        else{
            if(st.empty()) cout << "-1\n";
            else{
                int res=0;
                for(int i=0; i<30; ++i) if(!a[i]) res|=1<<i;
                cout << res << "\n";
            }
        }
    }
}
0