結果
問題 | No.130 XOR Minimax |
ユーザー |
|
提出日時 | 2022-05-10 15:59:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 961 bytes |
コンパイル時間 | 4,243 ms |
コンパイル使用メモリ | 253,008 KB |
最終ジャッジ日時 | 2025-01-29 05:31:39 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 4 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using ll = long long; ll n; vector<ll> a; ll dp[40][2]; ll dpx[40][2]; void solve(){ for(ll i = 40-2;i>=0;i--){ for(ll j = 0;j<2;j++){//to ll mn = LLONG_MAX/2; for(ll k = 0;k<2;k++){//from auto b = a; for(auto &l :b)l ^= dpx[i+1][k]+(j<<i); ll mnb = b[0]; for(auto &l:b)mnb = max(mnb,l); if(mn>mnb){ mn = mnb; dpx[i][j] = dpx[i+1][k] + (j<<i); } } } } ll mn = LLONG_MAX/2; { auto b = a; for(auto &l:b)l ^= dpx[0][0]; ll mxb = b[0]; for(auto &l:b)mxb = max(l,mxb); mn = min(mn,mxb); } { auto b = a; for(auto &l:b)l ^= dpx[0][1]; ll mxb = b[0]; for(auto &l:b)mxb = max(l,mxb); mn = min(mn,mxb); } //cout<<dpx[0][0] << ' '<<dpx[0][1]<<endl; cout<<mn<<endl; } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin >> n; a = vector<ll>(n); for(auto &i:a)cin >> i; solve(); }