結果
| 問題 |
No.130 XOR Minimax
|
| コンテスト | |
| ユーザー |
a3636tako
|
| 提出日時 | 2016-11-24 19:53:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 794 bytes |
| コンパイル時間 | 1,459 ms |
| コンパイル使用メモリ | 157,788 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 10:47:17 |
| 合計ジャッジ時間 | 2,905 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int N;
int A[1000005];
/*
int dfs(int bit, int l, int r){
if(bit < 0){
for(int i = l; i < r; i++){
}
}
int ll = l;
int rr = r - 1;
while(1){
while(ll < N && (A[ll] & (1 << bit)) == 0) ll++;
while(rr >= 0 && (A[rr] & (1 << bit)) != 1) rr--;
if(ll >= rr) break;
swap(A[ll], A[rr]);
ll++;
rr--;
}
return min(dfs(bit - 1, l, ll), dfs(bit - 1, rr + 1, r);
}
*/
int cnt[100][2];
int main(){
cin >> N;
for(int i = 0; i < N; i++){
cin >> A[i];
}
int ans = 0;
for(int i = 0; i < 32; i++){
cnt[i][0] = 0;
cnt[i][1] = 0;
for(int j = 0; j < N; j++){
if((A[j] & (1 << i))){
cnt[i][0]++;
}else{
cnt[i][1]++;
}
}
if(cnt[i][0] != 0 && cnt[i][1] != 0){
ans |= 1 << i;
}
}
cout << ans << endl;
}
a3636tako