結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-20 22:49:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,417 bytes |
| コンパイル時間 | 3,114 ms |
| コンパイル使用メモリ | 253,352 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-06-23 10:48:59 |
| 合計ジャッジ時間 | 9,379 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | WA * 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 if (st.size() == 1) cout << *st.begin() << '\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.size()) {
rep(i, M) if (x>>i&1) cnt[i]++;
st.insert(x);
continue;
}
if (st.count(x)) continue;
st.insert(x);
rep(i, M) {
if (x>>i&1) {
if (cnt[i]) 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;
}