結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-20 21:59:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 212 ms / 2,000 ms |
| コード長 | 935 bytes |
| コンパイル時間 | 1,962 ms |
| コンパイル使用メモリ | 174,604 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-06-23 09:58:44 |
| 合計ジャッジ時間 | 5,283 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int Q, cmd, x;
cin >> Q;
vector<int> cnt(30);
set<int> S;
while(Q--){
cin >> cmd;
if(cmd <= 2)cin >> x;
if(cmd == 1){
if(S.count(x))continue;
S.insert(x);
for(int i = 0; i < 30; i++){
if(x >> i & 1) cnt[i]++;
}
}else if(cmd == 2){
if(!S.count(x))continue;
S.erase(x);
for(int i = 0; i < 30; i++){
if(x >> i & 1) cnt[i]--;
}
}else{
if(S.empty()){
cout << -1 << '\n';
continue;
}
int ans = 0;
for(int i = 0; i < 30; i++){
if(cnt[i] == S.size())ans |= 1 << i;
}
cout << ans << '\n';
}
}
}