結果

問題 No.2195 AND Set
ユーザー twooimp2
提出日時 2024-03-29 19:32:37
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 1,094 bytes
コンパイル時間 24,203 ms
コンパイル使用メモリ 359,004 KB
最終ジャッジ日時 2025-02-20 14:37:38
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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