結果
問題 |
No.2195 AND Set
|
ユーザー |
|
提出日時 | 2023-02-15 18:52:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 206 ms / 2,000 ms |
コード長 | 945 bytes |
コンパイル時間 | 2,208 ms |
コンパイル使用メモリ | 200,024 KB |
最終ジャッジ日時 | 2025-02-10 15:45:03 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
#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"; } } } }