結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2023-01-20 21:24:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 415 ms / 2,000 ms |
| コード長 | 935 bytes |
| コンパイル時間 | 1,540 ms |
| コンパイル使用メモリ | 174,352 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-06-23 09:12:01 |
| 合計ジャッジ時間 | 7,642 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int Q;
cin >> Q;
vector<int> C(30, 0);
int cnt = 0;
set<int> st;
for (int i = 0; i < Q; i++){
int t;
cin >> t;
if (t == 1){
int x;
cin >> x;
if (st.count(x) == 0){
st.insert(x);
for (int j = 0; j < 30; j++){
if ((x >> j & 1) == 1){
C[j]++;
}
}
cnt++;
}
}
if (t == 2){
int x;
cin >> x;
if (st.count(x) == 1){
st.erase(x);
for (int j = 0; j < 30; j++){
if ((x >> j & 1) == 1){
C[j]--;
}
}
cnt--;
}
}
if (t == 3){
if (st.empty()){
cout << -1 << endl;
} else {
int ans = 0;
for (int j = 0; j < 30; j++){
if (C[j] == cnt){
ans |= 1 << j;
}
}
cout << ans << endl;
}
}
}
}
SSRS