結果

問題 No.3249 AND
ユーザー SnowBeenDiding
提出日時 2025-08-29 21:28:03
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 4,635 ms
コンパイル使用メモリ 335,012 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-29 23:57:21
合計ジャッジ時間 5,975 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(12);
    int ans = 0;
    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, 1, n + 1) {
        cin >> a[i];
        ans |= (i & a[i]);
    }
    rep(i, 1, n + 1) {
        if (ans & a[i] != a[i]) {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << ans << endl;
}
0