結果
問題 |
No.3249 AND
|
ユーザー |
![]() |
提出日時 | 2025-08-29 22:22:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,067 bytes |
コンパイル時間 | 3,375 ms |
コンパイル使用メモリ | 251,440 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-29 23:59:45 |
合計ジャッジ時間 | 5,304 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 WA * 1 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using i32 = int; using i64 = long long; using f64 = double; using p2 = pair<i64, i64>; using el = tuple<i64, i64, i64>; using mint = atcoder::modint998244353; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } i64 pow(i64 x, i64 n) { i64 res = 1; i64 t = x; while (n > 0) { if (n & 1) res *= t; t *= t; n >>= 1; } return res; } void _main() { i64 n; cin >> n; vector<i64> a(30, 1); bool ok = true; for (i64 i = 1; i <= n; i++) { i64 b; cin >> b; for (i64 j = 0; j < 30; j++) { i64 x = b >> j & 1, y = i >> j & 1; if (x == 1 && y == 0) ok = false; else if (x == 1 && y == 1) { if (a[j] == 0) ok = false; a[j] = 2; } else if (x == 0 && y == 1) { if (a[j] == 2) ok = false; a[j] = 0; } } } if (!ok) { cout << "-1\n"; return; } i64 ans = 0; for (i64 i = 0; i < 30; i++) { if (a[i] == 2) ans |= 1ll << i; } cout << ans << "\n"; }