結果

問題 No.130 XOR Minimax
ユーザー kotatsugamekotatsugame
提出日時 2020-02-23 07:12:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 434 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 73,184 KB
実行使用メモリ 28,120 KB
最終ジャッジ日時 2023-10-10 00:26:57
合計ジャッジ時間 2,825 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
4,660 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 45 ms
28,108 KB
testcase_05 AC 71 ms
28,120 KB
testcase_06 AC 63 ms
16,352 KB
testcase_07 AC 74 ms
16,256 KB
testcase_08 AC 64 ms
6,160 KB
testcase_09 AC 13 ms
5,476 KB
testcase_10 AC 19 ms
6,208 KB
testcase_11 AC 65 ms
14,304 KB
testcase_12 AC 7 ms
4,364 KB
testcase_13 AC 54 ms
12,128 KB
testcase_14 AC 71 ms
5,904 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 49 ms
4,864 KB
testcase_17 AC 51 ms
4,876 KB
testcase_18 AC 56 ms
5,204 KB
testcase_19 AC 66 ms
5,552 KB
testcase_20 AC 32 ms
4,476 KB
testcase_21 AC 70 ms
5,776 KB
testcase_22 AC 15 ms
4,348 KB
testcase_23 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:21:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   21 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
int f(vector<int>a,int id)
{
	if(a.size()==1)return 0;
	if(id==0)return 0;
	vector<int>x,y;
	for(int u:a)
	{
		if(u&id)x.push_back(u^id);
		else y.push_back(u);
	}
	if(x.empty())return f(y,id/2);
	else if(y.empty())return f(x,id/2);
	else
	{
		return id+min(f(x,id/2),f(y,id/2));
	}
}
main()
{
	int N;
	cin>>N;
	vector<int>A(N);
	for(int&a:A)cin>>a;
	cout<<f(A,1<<30)<<endl;
}
0