結果

問題 No.130 XOR Minimax
ユーザー CleyLCleyL
提出日時 2020-02-25 03:18:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,245 bytes
コンパイル時間 961 ms
コンパイル使用メモリ 99,880 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 06:12:03
合計ジャッジ時間 13,556 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 OLE -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 OLE -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

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);
  cout << beg << " " << b[en] << " " << k << endl;
  if(x == b.begin()+beg && k != b[en]){
    if(k%2)return ans;
    return dfs(beg,en,k+(km/2),km/2,ans);
  }else if(x == b.begin()+en && k != b[en]){
    if(k%2)return ans;
    return dfs(beg,en,k-(km/2),km/2,ans);
  }else{
    cout << "!!" <<ans << " " << km << endl;
    ans += km;
    
    if(k%2)return ans;
    return min(dfs(x-b.begin(),en,k+(km/2),km/2,ans),dfs(beg,x-b.begin()-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,(2LL<<29LL),(2LL<<29LL),0) << endl;
}
0