結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-20 21:48:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 237 ms / 2,000 ms |
| コード長 | 1,483 bytes |
| コンパイル時間 | 3,301 ms |
| コンパイル使用メモリ | 194,832 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-06-23 09:44:42 |
| 合計ジャッジ時間 | 6,964 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
#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]++;
}
}
}
}
}