結果
問題 | No.2195 AND Set |
ユーザー |
![]() |
提出日時 | 2023-01-20 21:50:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 457 ms / 2,000 ms |
コード長 | 926 bytes |
コンパイル時間 | 2,146 ms |
コンパイル使用メモリ | 201,712 KB |
最終ジャッジ日時 | 2025-02-10 04:45:49 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1001001001; const ll LINF = 1001002003004005006ll; //const int mod = 1000000007; //const int mod = 998244353; int main() { int q; cin >> q; set<ll> st; vector<ll> bit(30); rep(qi, 0, q) { ll t, x; cin >> t; if (t == 1) { cin >> x; if (st.count(x)) continue; st.insert(x); rep(i, 0, 30) if (!(x>>i&1)) bit[i]++; } else if (t == 2) { cin >> x; if (st.count(x)) { st.erase(x); rep(i, 0, 30) if (!(x>>i&1)) bit[i]--; } } else { if (!st.size()) cout << -1 << endl; else { ll tmp = 1; ll ans = 0; rep(i, 0, 30) { if (!bit[i]) ans += tmp; tmp *= 2; } cout << ans << endl; } } } return 0; }