結果

問題 No.2195 AND Set
ユーザー momoyuumomoyuu
提出日時 2023-05-19 21:31:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 408 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 3,328 ms
コンパイル使用メモリ 249,852 KB
実行使用メモリ 8,068 KB
最終ジャッジ日時 2023-08-22 23:36:26
合計ジャッジ時間 11,365 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 269 ms
4,380 KB
testcase_03 AC 304 ms
4,992 KB
testcase_04 AC 272 ms
4,380 KB
testcase_05 AC 343 ms
4,928 KB
testcase_06 AC 342 ms
4,892 KB
testcase_07 AC 293 ms
4,384 KB
testcase_08 AC 347 ms
4,952 KB
testcase_09 AC 294 ms
4,380 KB
testcase_10 AC 377 ms
8,068 KB
testcase_11 AC 390 ms
7,956 KB
testcase_12 AC 391 ms
8,028 KB
testcase_13 AC 408 ms
7,944 KB
testcase_14 AC 386 ms
7,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int q;
    cin>>q;
    set<ll> s;
    vector<int> cnt(30,0);
    while(q--){
        int t;
        cin>>t;
        if(t==1){
            ll x;
            cin>>x;
            if(s.count(x)) continue;
            s.insert(x);
            for(int i = 0;i<30;i++) if(x>>i&1) cnt[i]++;
        }else if(t==2){
            ll x;
            cin>>x;
            if(s.count(x)){
                s.erase(x);
                for(int i = 0;i<30;i++) if(x>>i&1) cnt[i]--;
            }
        }else{
            ll ans = 0;
            if(s.size()==0) ans = -1;
            else{
                for(int i = 0;i<30;i++) if(s.size()==cnt[i]) ans |= 1 << i;
            }
            cout<<ans<<endl;
        }
    }
}


0