結果

問題 No.2195 AND Set
ユーザー twooimp2twooimp2
提出日時 2024-03-29 19:32:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 1,094 bytes
コンパイル時間 7,889 ms
コンパイル使用メモリ 306,924 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-03-29 19:32:52
合計ジャッジ時間 13,115 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 172 ms
6,676 KB
testcase_03 AC 192 ms
6,676 KB
testcase_04 AC 171 ms
6,676 KB
testcase_05 AC 257 ms
6,676 KB
testcase_06 AC 244 ms
6,676 KB
testcase_07 AC 211 ms
6,676 KB
testcase_08 AC 244 ms
6,676 KB
testcase_09 AC 202 ms
6,676 KB
testcase_10 AC 286 ms
8,192 KB
testcase_11 AC 258 ms
8,320 KB
testcase_12 AC 254 ms
8,320 KB
testcase_13 AC 255 ms
8,192 KB
testcase_14 AC 283 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;

void IO(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

int main(){
  IO();
  ll q;
  cin>>q;
  set<ll> st;
  vector<ll> c0(30,0),c1(30,0);
  while(q--){
    ll t;
    cin>>t;
    if(t==1){
      ll x;
      cin>>x;
      if(st.find(x)==st.end()){
        st.insert(x);
        for(ll i=0;i<30;i++){
          if(x&(1<<i)){
            c1[i]++;
          }else{
            c0[i]++;
          }
        }
      }
    }else if(t==2){
      ll x;
      cin>>x;
      if(st.find(x)!=st.end()){
        st.erase(x);
        for(ll i=0;i<30;i++){
          if(x&(1<<i)){
            c1[i]--;
          }else{
            c0[i]--;
          }
        }
      }
    }else{
      ll ans=0;
      if(st.size()>0){
        for(ll i=0;i<30;i++){
          if(c0[i]==0){
            ans+=(1<<i);
          }
        }
      }else{
        ans--;
      }
      cout<<ans<<endl;
    }
  }
}
0