結果
問題 | No.2195 AND Set |
ユーザー |
|
提出日時 | 2023-11-03 06:08:50 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 389 ms / 2,000 ms |
コード長 | 1,158 bytes |
コンパイル時間 | 3,165 ms |
コンパイル使用メモリ | 249,580 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-09-25 18:33:21 |
合計ジャッジ時間 | 10,590 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i<n; ++i) #define repl(i,m,n) for(ll i=m; i<n; ++i) int main(){ multiset<int> st; vector<int> cnt(30,0); int Q; cin >> Q; rep(q, 0, Q){ int type; cin >> type; if(type == 1){ int x; cin >> x; if(st.find(x) != st.end()) continue; st.insert(x); rep(i, 0, 30){ if(x & (1<<i)) cnt[i]++; } }else if(type == 2){ int x; cin >> x; auto itr = st.find(x); if(itr == st.end()) continue; st.erase(itr); rep(i, 0, 30){ if(x & (1<<i)) cnt[i]--; } }else{ int ans = 0; int sz = st.size(); if(sz == 0){ cout << -1 << endl; }else{ rep(i, 0, 30){ if(cnt[i] == sz){ ans += (1<<i); } } cout << ans << endl; } } } return 0; }