結果

問題 No.2195 AND Set
ユーザー hourenhouren
提出日時 2023-01-20 22:06:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 1,248 bytes
コンパイル時間 1,884 ms
コンパイル使用メモリ 172,528 KB
実行使用メモリ 8,220 KB
最終ジャッジ日時 2023-09-05 14:23:58
合計ジャッジ時間 5,033 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 125 ms
4,376 KB
testcase_03 AC 148 ms
4,924 KB
testcase_04 AC 124 ms
4,384 KB
testcase_05 AC 130 ms
5,112 KB
testcase_06 AC 136 ms
4,840 KB
testcase_07 AC 98 ms
4,380 KB
testcase_08 AC 128 ms
4,924 KB
testcase_09 AC 89 ms
4,380 KB
testcase_10 AC 187 ms
7,944 KB
testcase_11 AC 185 ms
7,932 KB
testcase_12 AC 181 ms
7,992 KB
testcase_13 AC 183 ms
8,220 KB
testcase_14 AC 186 ms
7,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62);
constexpr int INF = (1 << 30);

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    vector<int> cnt(30,0);
    set<int> se;
    rep(houren,q){
        int t;
        cin >> t;
        if(t==3){
            int ans = 0;
            rep(i,30){
                ans += ((cnt[i]==se.size()) << i);
            }
            if(se.empty()) ans = -1;
            cout << ans << '\n';
        }else{
            int x;
            cin >> x;
            if(t==1){
                if(se.count(x)) continue;
                se.insert(x);
                rep(i,30) cnt[i] += x&1, x >>= 1;
            }else{
                if(!se.count(x)) continue;
                se.erase(x);
                rep(i,30) cnt[i] -= x&1, x >>= 1;
            }
        }
    }
    return 0;
}
0