結果

問題 No.130 XOR Minimax
ユーザー snteasntea
提出日時 2016-07-21 13:48:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,685 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 160,740 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 19:32:30
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 16 ms
5,376 KB
testcase_05 AC 21 ms
5,376 KB
testcase_06 AC 18 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 12 ms
5,376 KB
testcase_14 WA -
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 #

#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const long long INF = 1e10;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
#else
	#define DEBUG(x) true
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef pair<int,int> P;
typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	cin >> n;
	vector<LL> a(n);
	REP(i,n) cin >> a[i];
	vector<LL> dp(n,0);
	REP(i,33){
		LL ma = INF;
		LL ab = 0;
		REP(b,2){
			LL mat = 0;
			REP(j,n){
				mat = max(((a[j]&(1<<i))^(LL(b)<<i))|dp[j], mat);
			}
			if(chmin(ma,mat)) ab = b;
		}
		// DEBUG(ab);
		// DEBUG(ma);
		REP(j,n){
			dp[j] |= (((a[j])&(LL(1)<<i))^(ab<<i));
		}
	}
	cout << *max_element(ALL(dp)) << endl;
	return 0;
}
0