結果
| 問題 |
No.130 XOR Minimax
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-23 07:12:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 5,000 ms |
| コード長 | 434 bytes |
| コンパイル時間 | 733 ms |
| コンパイル使用メモリ | 74,264 KB |
| 実行使用メモリ | 28,480 KB |
| 最終ジャッジ日時 | 2024-09-12 22:55:29 |
| 合計ジャッジ時間 | 2,684 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
21 | main()
| ^~~~
ソースコード
#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;
}