結果
問題 | No.2195 AND Set |
ユーザー |
|
提出日時 | 2023-01-20 22:51:15 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 442 ms / 2,000 ms |
コード長 | 1,123 bytes |
コンパイル時間 | 3,306 ms |
コンパイル使用メモリ | 252,936 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-06-23 10:50:53 |
合計ジャッジ時間 | 9,470 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h>#define rep(i, n) for (int i = 0; i < (n); ++i)using namespace std;int main() {int q;cin >> q;set<int> st;const int M = 30;vector<int> cnt(M);int ans = 0;rep(qi, q) {int type;cin >> type;if (type == 3) {if (!st.size()) cout << -1 << '\n';else {int ans = 0;rep(i, M) {if (cnt[i] == int(st.size())) ans += 1<<i;}cout << ans << '\n';}}else {int x;cin >> x;if (type == 1) {if (st.count(x)) continue;st.insert(x);rep(i, M) {if (x>>i&1) cnt[i]++;}}else {if (!st.count(x)) continue;st.erase(x);rep(i, M) if (x>>i&1) cnt[i]--;}// rep(i, M) cerr << cnt[i] << " \n"[i == M-1];}// cerr << st.size() << '\n';}return 0;}