結果

問題 No.2195 AND Set
ユーザー Lim AloysiusLim Aloysius
提出日時 2023-01-20 21:48:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 1,483 bytes
コンパイル時間 2,063 ms
コンパイル使用メモリ 193,416 KB
実行使用メモリ 8,276 KB
最終ジャッジ日時 2023-09-05 14:03:16
合計ジャッジ時間 5,831 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 130 ms
4,376 KB
testcase_03 AC 159 ms
4,900 KB
testcase_04 AC 129 ms
4,380 KB
testcase_05 AC 143 ms
4,944 KB
testcase_06 AC 144 ms
4,836 KB
testcase_07 AC 102 ms
4,380 KB
testcase_08 AC 143 ms
4,836 KB
testcase_09 AC 92 ms
4,376 KB
testcase_10 AC 235 ms
8,212 KB
testcase_11 AC 235 ms
7,956 KB
testcase_12 AC 235 ms
8,276 KB
testcase_13 AC 236 ms
8,004 KB
testcase_14 AC 234 ms
8,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef MY_LOCAL
#include "D://competitive_programming/debug/debug.h"
#define debug(x) cerr << "[" << #x<< "]:"<<x<<"\n"
#else
#define debug(x) 
#endif
#define REP(i, n) for(int i = 0; i < n; i ++)
#define REPL(i,m, n) for(int i = m; i < n; i ++)
#define SORT(arr) sort(arr.begin(), arr.end())
#define LSOne(S) ((S)&-(S))
#define M_PI 3.1415926535897932384
#define INF 1e18
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef double ld;
typedef tree<int,null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int q;cin>>q;
	set<int> ss;
	vi curct(30, 0);
	REP(i, q) {
		int ty;cin>>ty;
		if (ty == 3) {
			if (ss.empty()) {
				cout<<-1<<"\n";
			} else {
				int curans = 0;
				REP(j, 30) {
					if (curct[j] == (int)ss.size()) {
						curans += (1LL<<j);
					}
 				}
 				cout<<curans<<"\n";
			}
		} else if (ty == 2) {
			int x;cin>>x;
			if (ss.find(x) == ss.end()) continue;
			ss.erase(x);
			REP(j, 30 ){
				if ((1LL<<j)&x) {
					curct[j]--;
				}
			}
		} else {
			int x;cin>>x;
			if (ss.find(x) != ss.end()) continue;
			ss.insert(x);
			REP(j, 30 ){
				if ((1LL<<j)&x) {
					curct[j]++;
				}
			}
		}
	}
}
0