結果

問題 No.2195 AND Set
ユーザー V_MelvilleV_Melville
提出日時 2023-01-20 22:37:27
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,140 bytes
コンパイル時間 3,285 ms
コンパイル使用メモリ 248,900 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-05 14:58:38
合計ジャッジ時間 8,678 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1,732 ms
4,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

int main() {
    int q;
    cin >> q;
    
    set<int> st;
    const int M = 30;
    vector<int> cnt(M);
    int ans = 0;
    rep(qi, q) {
        int type;
        cin >> type;
        if (type == 3) {
            if (!st.size()) cout << -1 << '\n';
            // else if (st.size() == 1) cout << *st.begin() << '\n';
            else {
                int ans = (1<<M)-1;
                for (int x : st) ans &= x;
                cout << ans << '\n';
            }
        }
        else {
            int x;
            cin >> x;
            if (type == 1) {
                if (!st.size()) ans = x;
                if (st.count(x)) continue;
                st.insert(x);
                // rep(i, M) if (x>>i&1) cnt[i]++;
            }
            else {
                if (!st.count(x)) continue;
                st.erase(x);
                // rep(i, M) if (x>>i&1) cnt[i]--;
            }
            // rep(i, M) cerr << cnt[i] << " \n"[i == M-1];
        }
        
        // cerr << st.size() << '\n';
    }
    
    return 0;
}
0