結果
問題 | No.2195 AND Set |
ユーザー | HIcoder |
提出日時 | 2023-07-18 19:00:22 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 458 ms / 2,000 ms |
コード長 | 1,854 bytes |
コンパイル時間 | 1,454 ms |
コンパイル使用メモリ | 111,232 KB |
実行使用メモリ | 8,428 KB |
最終ジャッジ日時 | 2023-10-18 22:16:58 |
合計ジャッジ時間 | 7,938 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 317 ms
4,552 KB |
testcase_03 | AC | 355 ms
5,324 KB |
testcase_04 | AC | 316 ms
4,552 KB |
testcase_05 | AC | 388 ms
5,504 KB |
testcase_06 | AC | 382 ms
5,504 KB |
testcase_07 | AC | 332 ms
4,356 KB |
testcase_08 | AC | 378 ms
5,320 KB |
testcase_09 | AC | 322 ms
4,348 KB |
testcase_10 | AC | 451 ms
8,424 KB |
testcase_11 | AC | 452 ms
8,428 KB |
testcase_12 | AC | 449 ms
8,428 KB |
testcase_13 | AC | 448 ms
8,424 KB |
testcase_14 | AC | 458 ms
8,428 KB |
ソースコード
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<numeric> #include<queue> #include<cmath> #include<tuple> using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair<ll,ll> P; typedef pair<int,P> PP; const ll MOD=1e9+7; int main(){ int Q; cin>>Q; vector<int> ans(31,0); set<int> st; vector<int> c; for(int q=0;q<Q;q++){ int t; cin>>t; if(t==1){ int x; cin>>x; if(!st.count(x)){ st.insert(x); { int i=0; while(x>0){ if(x&1){ ans[i]++; } i++; x/=2; } } } }else if(t==2){ int x; cin>>x; if(st.count(x)){ st.erase(x); { int i=0; while(x>0){ if(x&1){ ans[i]--; } i++; x/=2; } } } }else{ //t==3 int output=-1; if(st.size()>0){ output=0; for(int i=0;i<=30;i++){ if(ans[i]==st.size()){ output|=1<<i; } } } c.push_back(output); //cout<<output<<endl; } } for(int v:c){ cout<<v<<endl; } }