結果

問題 No.130 XOR Minimax
ユーザー conan1024haoconan1024hao
提出日時 2020-01-11 15:35:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 2,741 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 113,432 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2023-10-10 00:26:04
合計ジャッジ時間 3,442 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
5,580 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 7 ms
4,348 KB
testcase_05 AC 14 ms
4,348 KB
testcase_06 AC 68 ms
14,080 KB
testcase_07 AC 70 ms
13,988 KB
testcase_08 AC 61 ms
9,056 KB
testcase_09 AC 10 ms
4,780 KB
testcase_10 AC 16 ms
5,456 KB
testcase_11 AC 57 ms
9,516 KB
testcase_12 AC 6 ms
4,352 KB
testcase_13 AC 47 ms
8,476 KB
testcase_14 AC 74 ms
8,124 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 45 ms
6,560 KB
testcase_17 AC 48 ms
6,916 KB
testcase_18 AC 53 ms
7,024 KB
testcase_19 AC 67 ms
7,820 KB
testcase_20 AC 28 ms
5,452 KB
testcase_21 AC 74 ms
8,020 KB
testcase_22 AC 12 ms
4,420 KB
testcase_23 AC 5 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码!Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
int N;
set<int> S;
vector<int> v;

int hoge(int d,vector<int>& v) {
    if(v.size()<=1) return 0;
    int i,j;
    vector<int> w[2];
    for(int i=0;i<siz(v);i++) {
        int x=v[i];
        w[(x>>d)&1].push_back(x^(x&(1<<d)));
    }
    
    if(w[0].size()==0) return hoge(d-1,w[1]);
    if(w[1].size()==0) return hoge(d-1,w[0]);
    
    return (1<<d)+min(hoge(d-1,w[0]),hoge(d-1,w[1]));
}

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int i,j,k,l,r,x,y; string s;
    cin>>N;
    for(int i=0;i<N;i++) {cin>>x; S.insert(x);}
    for(auto it=S.begin();it!=S.end();it++) v.push_back(*it);
    
    cout<<hoge(29,v)<< endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







0