結果

問題 No.2195 AND Set
コンテスト
ユーザー a01sa01to
提出日時 2024-02-27 00:01:10
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 900 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,302 ms
コンパイル使用メモリ 199,332 KB
最終ジャッジ日時 2026-07-03 21:16:51
合計ジャッジ時間 2,334 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:13: error: ‘class std::set<int>’ has no member named ‘contains’
   23 |       if (s.contains(x)) continue;
      |             ^~~~~~~~
main.cpp:30:14: error: ‘class std::set<int>’ has no member named ‘contains’
   30 |       if (!s.contains(x)) continue;
      |              ^~~~~~~~

ソースコード

diff #
raw source code

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