結果

問題 No.130 XOR Minimax
ユーザー CleyLCleyL
提出日時 2020-02-25 03:39:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 1,312 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 97,720 KB
実行使用メモリ 5,188 KB
最終ジャッジ日時 2023-10-10 00:27:00
合計ジャッジ時間 2,428 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 12 ms
4,988 KB
testcase_05 AC 18 ms
5,000 KB
testcase_06 AC 15 ms
4,864 KB
testcase_07 AC 17 ms
5,188 KB
testcase_08 AC 21 ms
4,992 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 7 ms
4,352 KB
testcase_11 AC 19 ms
4,552 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 16 ms
4,728 KB
testcase_14 AC 25 ms
4,756 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 17 ms
4,348 KB
testcase_17 AC 19 ms
4,348 KB
testcase_18 AC 20 ms
4,348 KB
testcase_19 AC 24 ms
4,616 KB
testcase_20 AC 12 ms
4,348 KB
testcase_21 AC 25 ms
4,936 KB
testcase_22 AC 7 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

typedef pair<int,int> P;
typedef long long ll;



__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
vector<ll> b;
int dfs(int beg,int en,ll k,ll km,int ans){
  auto x = lower_bound(b.begin()+beg,b.begin()+en,k)-b.begin();
  //cout << beg << " " << en << " " << x << " " << k << endl;
  if(x == beg){
    if(k%2)return ans;
    //cout << beg << " " << en << endl;
    return dfs(beg,en,k+(km/2),km/2,ans);
  }else if(x == en && k > b[en]){
    if(k%2)return ans;
    //cout << beg << " " << en << endl;
    return dfs(beg,en,k-(km/2),km/2,ans);
  }else{
    ans += km;
    if(k%2)return ans;
    //cout << x << " " << en  << ":"  << beg << " " << x-1<< endl;
    return min(dfs(x,en,k+(km/2),km/2,ans),dfs(beg,x-1,k-(km/2),km/2,ans));
  }
}
int main() { 
  int n;cin>>n;
  ll a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
    b.push_back(a[i]);
  }
  sort(b.begin(),b.end());
  //b.push_back((2LL<<30LL));
  cout << dfs(0,n-1,(2LL<<29LL),(2LL<<29LL),0) << endl;
}
0