結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-02-26 17:08:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 147 ms / 2,000 ms |
| コード長 | 961 bytes |
| コンパイル時間 | 658 ms |
| コンパイル使用メモリ | 60,508 KB |
| 実行使用メモリ | 7,560 KB |
| 最終ジャッジ日時 | 2024-09-14 07:12:45 |
| 合計ジャッジ時間 | 5,137 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2195.cc: No.2195 AND Set - yukicoder
*/
#include<cstdio>
#include<unordered_set>
#include<algorithm>
using namespace std;
/* constant */
const int BN = 30;
/* typedef */
/* global variables */
int cs[BN][2];
/* subroutines */
/* main */
int main() {
int qn;
scanf("%d", &qn);
unordered_set<int> xs;
while (qn--) {
int op;
scanf("%d", &op);
if (op == 1) {
int x;
scanf("%d", &x);
if (! xs.count(x)) {
xs.insert(x);
for (int i = 0; i < BN; i++)
cs[i][(x >> i) & 1]++;
}
}
else if (op == 2) {
int x;
scanf("%d", &x);
if (xs.count(x)) {
xs.erase(x);
for (int i = 0; i < BN; i++)
cs[i][(x >> i) & 1]--;
}
}
else {
if (xs.empty()) puts("-1");
else {
int s = 0;
for (int i = 0, bi = 1; i < BN; i++, bi <<= 1)
if (cs[i][0] == 0 && cs[i][1] > 0) s |= bi;
printf("%d\n", s);
}
}
}
return 0;
}
tnakao0123