結果
| 問題 |
No.130 XOR Minimax
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-02-15 23:13:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 622 bytes |
| コンパイル時間 | 227 ms |
| コンパイル使用メモリ | 36,340 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 20:24:12 |
| 合計ジャッジ時間 | 1,440 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d", A+i);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
#include <limits>
int main(){
int N;
scanf("%d", &N);
int A[100000];
for(int i=0;i<N;i++){
scanf("%d", A+i);
}
int mask = 0;
for(int i=30;i>=0;i--){
int mn = std::numeric_limits<int>::max(), mn_f = 0;
for(int j=0;j<N;j++){
if((A[j] & ((1 << i) - 1)) < mn){
mn = A[j] & ((1 << i) - 1);
mn_f = A[j] >> i & 1;
}
}
mask |= mn_f << i;
}
int res = 0;
for(int i=0;i<N;i++){
res = std::max(res, A[i] ^ mask);
}
printf("%d\n", res);
}
tottoripaper