結果
| 問題 | No.3249 AND |
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2025-12-25 02:15:09 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 902 bytes |
| 記録 | |
| コンパイル時間 | 5,058 ms |
| コンパイル使用メモリ | 335,024 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-25 02:18:01 |
| 合計ジャッジ時間 | 6,670 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 23 |
ソースコード
#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 & i) != a[i]) {
cout << "-1" << endl;
return 0;
}
}
if (ans == 0) {
ans = -1;
rep(i, 1, 1000) {
bool ok = 1;
int test = 1 << i;
rep(j, 1, n + 1) {
if ((test & j) != a[j]) ok = 0;
}
if (ok) {
ans = test;
break;
}
}
}
cout << ans << endl;
}
SnowBeenDiding