結果
| 問題 | No.3249 AND |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-14 19:51:22 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 517 bytes |
| 記録 | |
| コンパイル時間 | 332 ms |
| コンパイル使用メモリ | 82,688 KB |
| 実行使用メモリ | 102,796 KB |
| 最終ジャッジ日時 | 2026-02-14 19:51:27 |
| 合計ジャッジ時間 | 5,033 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 WA * 3 |
ソースコード
# https://yukicoder.me/problems/no/3249
MOD = 10 ** 9 + 7
def main():
N = int(input())
B = list(map(int, input().split()))
n = N
k = 0
while n > 0:
k += 1
n //= 2
candidate = 0
for i in range(k):
b = B[(1 << i) - 1]
o = 1 if b & (1 << i) > 0 else 0
candidate += o * (1 << i)
for i in range(N):
if B[i] != (i + 1) & candidate:
print(-1)
return
print(candidate)
if __name__ == "__main__":
main()