結果
問題 |
No.2195 AND Set
|
ユーザー |
![]() |
提出日時 | 2024-02-27 00:01:10 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 364 ms / 2,000 ms |
コード長 | 900 bytes |
コンパイル時間 | 6,721 ms |
コンパイル使用メモリ | 264,100 KB |
最終ジャッジ日時 | 2025-02-19 21:39:03 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); ++i) int main() { int q; cin >> q; set<int> s; vector cnt(30, vector<int>(2, 0)); while (q--) { int t; cin >> t; if (t == 1) { int x; cin >> x; if (s.contains(x)) continue; s.insert(x); rep(i, 30) cnt[i][(x >> i) & 1]++; } else if (t == 2) { int x; cin >> x; if (!s.contains(x)) continue; s.erase(x); rep(i, 30) cnt[i][(x >> i) & 1]--; } else { if (s.empty()) { cout << -1 << endl; continue; } int res = 0; rep(i, 30) { if (cnt[i][0] > 0) continue; res |= 1 << i; } cout << res << endl; } } return 0; }