結果

問題 No.2195 AND Set
ユーザー 👑 OnjoujiTokiOnjoujiToki
提出日時 2023-01-20 22:26:27
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 1,949 bytes
コンパイル時間 1,392 ms
コンパイル使用メモリ 134,376 KB
実行使用メモリ 8,028 KB
最終ジャッジ日時 2023-09-05 14:46:19
合計ジャッジ時間 6,498 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 235 ms
4,376 KB
testcase_03 AC 268 ms
4,876 KB
testcase_04 AC 238 ms
4,376 KB
testcase_05 AC 240 ms
4,880 KB
testcase_06 AC 251 ms
4,868 KB
testcase_07 AC 194 ms
4,380 KB
testcase_08 AC 235 ms
4,876 KB
testcase_09 AC 186 ms
4,376 KB
testcase_10 AC 342 ms
8,004 KB
testcase_11 AC 340 ms
7,984 KB
testcase_12 AC 344 ms
7,996 KB
testcase_13 AC 347 ms
7,992 KB
testcase_14 AC 341 ms
8,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* 💕💕💕💕💕
💗💗💗💗💗
  /)/)
( . .)
( づ💗

    💗💗💗  💗💗💗
  💗💗💗💗💗💗💗💗💗
  💗💗💗💗💗💗💗💗💗
    💗💗💗💗💗💗💗
      💗💗💗💗💗
        💗💗💗
          💗

*/

#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;
}
0