結果

問題 No.2195 AND Set
コンテスト
ユーザー twooimp2
提出日時 2024-03-29 19:32:37
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 1,094 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,059 ms
コンパイル使用メモリ 306,812 KB
実行使用メモリ 12,016 KB
最終ジャッジ日時 2026-07-04 07:06:59
合計ジャッジ時間 8,929 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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