結果
問題 | No.2195 AND Set |
ユーザー | nyya |
提出日時 | 2023-01-21 14:12:53 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 544 ms / 2,000 ms |
コード長 | 1,321 bytes |
コンパイル時間 | 3,834 ms |
コンパイル使用メモリ | 233,448 KB |
実行使用メモリ | 16,988 KB |
最終ジャッジ日時 | 2023-09-06 03:34:50 |
合計ジャッジ時間 | 11,286 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 317 ms
6,224 KB |
testcase_03 | AC | 340 ms
6,336 KB |
testcase_04 | AC | 307 ms
6,336 KB |
testcase_05 | AC | 415 ms
8,172 KB |
testcase_06 | AC | 410 ms
8,200 KB |
testcase_07 | AC | 372 ms
7,812 KB |
testcase_08 | AC | 396 ms
8,064 KB |
testcase_09 | AC | 363 ms
7,764 KB |
testcase_10 | AC | 543 ms
16,956 KB |
testcase_11 | AC | 544 ms
16,988 KB |
testcase_12 | AC | 527 ms
16,892 KB |
testcase_13 | AC | 533 ms
16,908 KB |
testcase_14 | AC | 537 ms
16,956 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(),x.end() typedef long long ll; //using mint = modint; using mint = modint998244353; using P = pair<int, int>; const ll INF=1LL<<60, dx[]={0,1,0,-1},dy[]={1,0,-1,0}; template <typename T> inline bool chmin(T& a,const T&b) {if(a>b){a=b; return 1;} return 0;} template <typename T> inline bool chmax(T& a,const T&b) {if(a<b){a=b; return 1;} return 0;} int main(){ int q; cin >> q; vector<int> cnt(30); map<ll,int> mp; int tot=0; rep(qi,q) { int type; cin >> type; if(type==1) { ll x; cin >> x; if(!mp[x]) { mp[x]++; rep(i,30) if((1ll<<i)&x) cnt[i]++; tot++; } } else if(type==2) { ll x; cin >> x; if(mp[x]) { mp[x]--; rep(i,30) if((1ll<<i)&x) cnt[i]--; tot--; } } else { if(tot==0) cout << -1 << endl; else { ll ans=0; rep(i,30) if(cnt[i]==tot) ans+=(1ll<<i); cout << ans << endl; } } } return 0; }