結果
| 問題 |
No.3249 AND
|
| ユーザー |
|
| 提出日時 | 2025-08-29 23:40:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,053 bytes |
| コンパイル時間 | 2,030 ms |
| コンパイル使用メモリ | 195,992 KB |
| 実行使用メモリ | 11,556 KB |
| 最終ジャッジ日時 | 2025-09-05 11:40:21 |
| 合計ジャッジ時間 | 5,650 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | AC * 2 TLE * 1 -- * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<int> B(N);
for(auto &b : B) cin >> b;
int answer = 0;
for(int d=0; d<20; d++){
bool zero = true,one = true;
for(int i=0; i<N; i++){
int b = B.at(i);
int v = (b>>d)&1;
if((i+1)&(1<<d)){
if(v == 1) zero = false;
else one = false;
}
else{
if(v == 1) zero = false,one = false;
}
}
if(zero) continue;
else if(one) answer += 1<<d;
else{answer = -1; break;}
}
if(answer == 0){
for(int x=1; x<600000; x++){
bool ok = true;
for(int i=1; i<=N; i++){
int b = B.at(i-1);
if((i&x) == b) continue;
ok = false;
}
if(ok){cout << x << endl; return 0;}
}
cout << -1 << endl;
}
cout << answer << endl;
}