結果
問題 |
No.2195 AND Set
|
ユーザー |
|
提出日時 | 2024-04-11 17:36:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 536 ms / 2,000 ms |
コード長 | 953 bytes |
コンパイル時間 | 4,580 ms |
コンパイル使用メモリ | 256,324 KB |
最終ジャッジ日時 | 2025-02-20 23:53:30 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; int main() { int Q; cin >> Q; vector<int> bit(30, 0); set<int> st; while (Q--) { int t; cin >> t; if (t == 1) { int x; cin >> x; if (!st.count(x)) { st.insert(x); for (int i = 0; i < 30; i++) { if (1 & (x >> i)) { bit[i]++; } } } } else if (t == 2) { int x; cin >> x; if (st.count(x)) { st.erase(x); for (int i = 0; i < 30; i++) { if (1 & (x >> i)) { bit[i]--; } } } } else { if (st.size() == 0) cout << -1 << endl; else { int ans = 0; for (int i = 0; i < 30; i++) { if (bit[i] == st.size()) ans += 1 << i; } cout << ans << endl; } } } }