結果
| 問題 |
No.130 XOR Minimax
|
| コンテスト | |
| ユーザー |
IKyopro
|
| 提出日時 | 2020-01-11 01:38:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 949 bytes |
| コンパイル時間 | 1,974 ms |
| コンパイル使用メモリ | 199,304 KB |
| 最終ジャッジ日時 | 2025-01-08 17:03:40 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
vec<ll> A(N);
int h = 0;
for(int i=0;i<N;i++){
cin >> A[i];
for(int j=0;j<30;j++) if(A[i]&(1<<j)) h = j;
}
auto calc = [&](auto&& self,vec<ll> A,int bit)->ll{
bool ok = true;
int n = A.size();
if(n<=1 || bit<0) return 0;
vec<ll> X,Y;
for(int i=0;i<n;i++){
if(A[i]&(1<<bit)) X.push_back(A[i]%(1<<bit));
else Y.push_back(A[i]%(1<<bit));
}
if(X.empty() || Y.empty()) return (X.empty()? self(self,Y,bit-1):self(self,X,bit-1));
else return (1<<bit) + min(self(self,X,bit-1),self(self,Y,bit-1));
};
cout << calc(calc,A,h) << endl;
}
IKyopro