結果

問題 No.130 XOR Minimax
ユーザー %20%20
提出日時 2017-09-11 17:02:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 343 bytes
コンパイル時間 2,047 ms
コンパイル使用メモリ 201,872 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-10 00:20:30
合計ジャッジ時間 3,753 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 17 ms
4,348 KB
testcase_05 AC 42 ms
4,348 KB
testcase_06 AC 29 ms
4,356 KB
testcase_07 AC 40 ms
4,348 KB
testcase_08 AC 40 ms
4,348 KB
testcase_09 AC 7 ms
4,352 KB
testcase_10 AC 9 ms
4,348 KB
testcase_11 AC 31 ms
4,352 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 25 ms
4,352 KB
testcase_14 AC 41 ms
4,352 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 29 ms
4,352 KB
testcase_17 AC 30 ms
4,348 KB
testcase_18 AC 33 ms
4,348 KB
testcase_19 AC 38 ms
4,348 KB
testcase_20 AC 19 ms
4,352 KB
testcase_21 AC 41 ms
4,348 KB
testcase_22 AC 9 ms
4,352 KB
testcase_23 AC 4 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:15:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   15 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int N,a[100000];
int f(int s,int l,int r){
	if(s<0){
		return 0;
	}
	if((a[l]^a[r-1])&1<<s){
		int m=lower_bound(a+l,a+r,a[l]&-(1<<s)|1<<s)-a;
		return 1<<s|min(f(s-1,l,m),f(s-1,m,r));
	}else{
		return f(s-1,l,r);
	}
}
main(){
	cin>>N;
	for(int i=0;cin>>a[i++];);
	sort(a,a+N);
	cout<<f(29,0,N);
}
0