結果

問題 No.130 XOR Minimax
ユーザー cielciel
提出日時 2015-12-21 22:24:44
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 510 bytes
コンパイル時間 480 ms
コンパイル使用メモリ 45,536 KB
実行使用メモリ 813,708 KB
最終ジャッジ日時 2023-10-18 22:07:30
合計ジャッジ時間 3,067 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%d",&N);
      |         ~~~~~^~~~~~~~~
main.cpp:20:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         for(int i=0;i<N;i++)scanf("%d",&v[i]);
      |                             ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int dfs(int d,const vector<int> &_v){
	if(_v.size()<2)return 0;
	vector<vector<int> > v(2);
	for(auto &e:_v){
		int x=e&(1<<d);
		v[x>>d].push_back(e^x);
	}
	return v[0].empty()?dfs(d-1,v[1]):v[1].empty()?dfs(d-1,v[0]):(1<<d)+min(dfs(d-1,v[0]),dfs(d-1,v[1]));
}

int main(){
	int N;
	scanf("%d",&N);
	vector<int>v(N);
	for(int i=0;i<N;i++)scanf("%d",&v[i]);
	v.erase(unique(v.begin(),v.end()),v.end());
	printf("%d\n",dfs(29,v));
}
0