結果
| 問題 |
No.130 XOR Minimax
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-21 22:24:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 510 bytes |
| コンパイル時間 | 384 ms |
| コンパイル使用メモリ | 45,440 KB |
| 実行使用メモリ | 813,824 KB |
| 最終ジャッジ日時 | 2024-09-18 18:08:46 |
| 合計ジャッジ時間 | 2,853 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 1 |
| other | AC * 1 -- * 20 |
コンパイルメッセージ
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]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#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));
}