結果
問題 | No.2195 AND Set |
ユーザー |
![]() |
提出日時 | 2024-02-27 00:01:50 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 418 ms / 2,000 ms |
コード長 | 900 bytes |
コンパイル時間 | 3,031 ms |
コンパイル使用メモリ | 255,408 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-09-29 11:49:40 |
合計ジャッジ時間 | 9,057 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)#endifusing 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;}