結果
問題 |
No.2844 Birthday Party Decoration
|
ユーザー |
|
提出日時 | 2024-08-23 21:52:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,434 bytes |
コンパイル時間 | 1,850 ms |
コンパイル使用メモリ | 195,952 KB |
最終ジャッジ日時 | 2025-02-23 23:41:26 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 4 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin>>T; while(T--){ int N; ll X; cin>>N>>X; vector<int>C(N); vector<bool>flag(61); ll xr=0; for(int i=0;i<N;i++){ cin>>C[i]; xr^=1LL<<C[i]; flag[C[i]]=true; } if(X==0){ xr<<=1; cout<<xr<<"\n"; }else{ ll ans=0; int tp=-1; for(int b=60;b>=0;b--){ if(X>>b&1)tp=b; } for(int b=60;b>=0;b--){ if(!(X>>b&1)&&flag[b]){ ll y=1LL<<b,z=0; for(int i=b+1;i<=60;i++){ if(X>>i&1)y^=1LL<<i; } for(int i=0;i<b;i++){ if(X>>i&1)z^=1LL<<i; } z++; if(tp>b)ans=min(y-X,z); else ans=y-X; break; } } ans<<=1; cout<<ans<<"\n"; } } }