結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-20 22:37:27 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,140 bytes |
| コンパイル時間 | 2,864 ms |
| コンパイル使用メモリ | 251,456 KB |
| 実行使用メモリ | 11,804 KB |
| 最終ジャッジ日時 | 2024-06-23 10:35:13 |
| 合計ジャッジ時間 | 8,670 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 TLE * 1 -- * 11 |
ソースコード
#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 = (1<<M)-1;
for (int x : st) ans &= x;
cout << ans << '\n';
}
}
else {
int x;
cin >> x;
if (type == 1) {
if (!st.size()) ans = x;
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;
}