結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-08-23 21:13:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 961 bytes |
| コンパイル時間 | 3,715 ms |
| コンパイル使用メモリ | 250,036 KB |
| 最終ジャッジ日時 | 2025-02-23 23:26:40 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 4 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
int main(){
int _t;
cin>>_t;
rep(_,_t){
long long n,x;
cin>>n>>x;
long long f = 0;
rep(i,n){
int a;
cin>>a;
f |= 1LL<<a;
}
long long ox = x;
rep(i,60){
if((x>>i)&1){
f &= ~(1LL<<i);
}
}
if(f==0){
cout<<0<<endl;
continue;
}
long long msb = 0;
rep(i,60){
if((f>>i)&1)msb = 1LL<<i;
}
long long ans = Inf64;
if(ox>=msb){
long long t = ox;
rep(i,60){
if((1LL<<i)<=msb){
t |= 1LL<<i;
}
else{
if((t>>i)&1){
t ^= 1LL<<i;
break;
}
}
}
ans = min(ans,abs(t-ox));
}
rep(i,60){
if((1LL<<i)>=msb){
x &= ~(1LL<<i);
}
}
ans = min(ans,abs(msb-x));
cout<<ans*2<<endl;
}
return 0;
}
沙耶花