結果
問題 | No.2195 AND Set |
ユーザー |
|
提出日時 | 2023-01-20 22:26:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 320 ms / 2,000 ms |
コード長 | 1,949 bytes |
コンパイル時間 | 1,328 ms |
コンパイル使用メモリ | 131,768 KB |
最終ジャッジ日時 | 2025-02-10 05:00:37 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
/* 💕💕💕💕💕 💗💗💗💗💗 /)/) ( . .) ( づ💗 💗💗💗 💗💗💗 💗💗💗💗💗💗💗💗💗 💗💗💗💗💗💗💗💗💗 💗💗💗💗💗💗💗 💗💗💗💗💗 💗💗💗 💗 */ #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdint> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <unordered_map> #include <unordered_set> std::vector<int> get_divisors(int x, bool sorted = true) { std::vector<int> res; for (int i = 1; i <= x / i; i++) if (x % i == 0) { res.push_back(i); if (i != x / i) res.push_back(x / i); } if (sorted) std::sort(res.begin(), res.end()); return res; } void solve() { int q; std::set<int> s; int ans = (1 << 30) - 1; std::cin >> q; std::vector<int> cnt(30); while (q--) { int op, x; std::cin >> op; if (op == 3) { if (s.empty()) std::cout << -1 << '\n'; else { int ans = 0; for (int i = 0; i < 30; i++) { if (cnt[i] == (int)s.size()) { ans |= 1 << i; } } std::cout << ans << '\n'; } } else { std::cin >> x; if (op == 2) { if (s.find(x) == s.end()) continue; s.erase(x); for (int i = 0; i < 30; i++) { if (x >> i & 1) { cnt[i] -= 1; } } } else { if (s.find(x) != s.end()) continue; s.insert(x); for (int i = 0; i < 30; i++) { if (x >> i & 1) { cnt[i] += 1; } } } } } } int main() { std::cin.tie(nullptr); int t = 1; // std::cout << std::boolalpha; // std::cin >> t; while (t--) solve(); return 0; }