結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-09-12 11:25:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 210 ms / 2,000 ms |
| コード長 | 985 bytes |
| コンパイル時間 | 2,227 ms |
| コンパイル使用メモリ | 197,968 KB |
| 最終ジャッジ日時 | 2025-02-24 06:42:05 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int Q;
cin>>Q;
int cnt[30];
for(int i=0;i<30;i++)cnt[i]=0;
set<int>S;
while(Q--)
{
int t;
cin>>t;
if(t==1)
{
int x;
cin>>x;
if(S.find(x)==S.end())
{
S.insert(x);
for(int i=0;i<30;i++)cnt[i]+=(x>>i&1);
}
}
else if(t==2)
{
int x;
cin>>x;
if(S.find(x)!=S.end())
{
S.erase(S.find(x));
for(int i=0;i<30;i++)cnt[i]-=(x>>i&1);
}
}
else
{
if(S.empty())
{
cout<<"-1"<<'\n';
continue;
}
int ans=0;
for(int i=0;i<30;i++)ans+=(cnt[i]==S.size())*(1<<i);
cout<<ans<<'\n';
}
}
}
nonon