結果

問題 No.3249 AND
ユーザー GOTKAKO
提出日時 2025-08-29 23:31:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 195,516 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-05 11:40:01
合計ジャッジ時間 3,348 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#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){
        answer = 1;
        while(answer <= N) answer <<= 1;
    }
    /*
    ちがくね?
    1
    0
    ならx=2では
    */
    cout << answer << endl;
}
0