結果

問題 No.2195 AND Set
ユーザー ermine
提出日時 2023-01-20 22:11:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 410 ms / 2,000 ms
コード長 1,044 bytes
コンパイル時間 1,714 ms
コンパイル使用メモリ 201,632 KB
最終ジャッジ日時 2025-02-10 04:54:31
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
int main() {
int q;
cin>>q;
set<int> s;
vector<int> cnt(30);
while(q--){
int cmd,x;
cin>>cmd;
if(cmd==1){
cin>>x;
if(s.count(x)) continue;
s.insert(x);
bitset<30> bs(x);
for(int i=0; i<30; i++){
if(bs[i]) cnt[i]++;
}
}
if(cmd==2){
cin>>x;
if(!s.count(x)) continue;
s.erase(x);
bitset<30> bs(x);
for(int i=0; i<30; i++){
if(bs[i] && cnt[i]) cnt[i]--;
}
}
if(cmd==3){
int sz = (int)s.size();
if(sz==0){
cout << -1 << endl;
continue;
}
long long res = 0;
long long p=1;
for(int i=0; i<30; i++){
if(cnt[i] == sz) res += p;
p*=2;
}
cout << res << endl;
}
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0