結果
問題 | No.130 XOR Minimax |
ユーザー | 0w1 |
提出日時 | 2017-01-02 16:36:41 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 123 ms / 5,000 ms |
コード長 | 1,520 bytes |
コンパイル時間 | 1,899 ms |
コンパイル使用メモリ | 166,276 KB |
実行使用メモリ | 51,208 KB |
最終ジャッジ日時 | 2023-10-10 00:16:16 |
合計ジャッジ時間 | 4,032 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
23,888 KB |
testcase_01 | AC | 1 ms
4,352 KB |
testcase_02 | AC | 1 ms
4,352 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 13 ms
4,352 KB |
testcase_05 | AC | 19 ms
4,352 KB |
testcase_06 | AC | 31 ms
9,608 KB |
testcase_07 | AC | 31 ms
9,696 KB |
testcase_08 | AC | 107 ms
51,208 KB |
testcase_09 | AC | 8 ms
5,212 KB |
testcase_10 | AC | 11 ms
5,852 KB |
testcase_11 | AC | 33 ms
8,188 KB |
testcase_12 | AC | 5 ms
4,500 KB |
testcase_13 | AC | 27 ms
7,860 KB |
testcase_14 | AC | 123 ms
41,620 KB |
testcase_15 | AC | 2 ms
4,348 KB |
testcase_16 | AC | 84 ms
30,896 KB |
testcase_17 | AC | 87 ms
32,036 KB |
testcase_18 | AC | 95 ms
34,112 KB |
testcase_19 | AC | 111 ms
39,468 KB |
testcase_20 | AC | 54 ms
21,840 KB |
testcase_21 | AC | 122 ms
41,416 KB |
testcase_22 | AC | 25 ms
12,516 KB |
testcase_23 | AC | 8 ms
6,252 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef pair< int, int > pii; typedef vector< pii > vp; typedef vector< double > vd; typedef vector< vd > vvd; typedef vector< string > vs; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; int N; vi A; void init(){ cin >> N; A = vi( N ); for( int i = 0; i < N; ++i ){ cin >> A[ i ]; } } struct trie{ trie *ch[ 2 ]; trie(){ ch[ 0 ] = ch[ 1 ] = NULL; } } *root; void update( trie *&t, int lv, int v ){ if( lv < 0 ){ return; } if( t->ch[ v >> lv & 1 ] == NULL ){ t->ch[ v >> lv & 1 ] = new trie(); } update( t->ch[ v >> lv & 1 ], lv - 1, v ); } void preprocess(){ root = new trie(); for( int i = 0; i < N; ++i ){ update( root, 30, A[ i ] ); } } int dfs( const trie *t, int lv ){ if( lv < 0 ){ return 0; } if( t->ch[ 0 ] == NULL ){ return dfs( t->ch[ 1 ], lv - 1 ); } if( t->ch[ 1 ] == NULL ){ return dfs( t->ch[ 0 ], lv - 1 ); } return 1 << lv | min( dfs( t->ch[ 0 ], lv - 1 ), dfs( t->ch[ 1 ], lv - 1 ) ); } void solve(){ cout << dfs( root, 30 ) << endl; } signed main(){ ios::sync_with_stdio( 0 ); init(); preprocess(); solve(); return 0; }