結果
問題 | No.130 XOR Minimax |
ユーザー |
![]() |
提出日時 | 2016-06-19 14:55:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 95 ms / 5,000 ms |
コード長 | 855 bytes |
コンパイル時間 | 563 ms |
コンパイル使用メモリ | 68,308 KB |
実行使用メモリ | 16,196 KB |
最終ジャッジ日時 | 2024-09-12 22:40:52 |
合計ジャッジ時間 | 2,480 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:33:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:35:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | rep (i,n) scanf("%d",&v[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <iostream>#include <vector>#include <map>#include <algorithm>using namespace std;#define REP(i,s,e) for (i = s; i <= e; i++)#define rep(i,n) REP (i,0,(int)(n)-1)#define RREP(i,s,e) for (i = s; i >= e; i--)#define rrep(i,n) RREP (i,(int)(n)-1,0)#define INF (int)1e8#define MOD (int)(1e9+7)typedef long long ll;int dfs(int b, vector<int>& v) {if (b < 0)return 0;int i;vector<int> s[2];rep (i,v.size())s[v[i]>>b&1].push_back(v[i]&(1<<b)-1);if (s[0].size() == v.size())return dfs(b-1,s[0]);else if (s[1].size() == v.size())return dfs(b-1,s[1]);elsereturn min(dfs(b-1,s[0]),dfs(b-1,s[1])) + (1<<b);}int main(void) {int i, n;scanf("%d",&n);vector<int> v(n);rep (i,n) scanf("%d",&v[i]);cout << dfs(30,v) << endl;return 0;}