結果

問題 No.3249 AND
ユーザー sasa8uyauya
提出日時 2025-08-30 01:31:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 295 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,772 KB
実行使用メモリ 108,260 KB
最終ジャッジ日時 2025-09-05 11:41:09
合計ジャッジ時間 4,402 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(range(1,n+1))
b=list(map(int,input().split()))
c=0
for j in range(20):
  if all((b[i]>>j)&1==0 for i in range(n)):
    continue
  if any((a[i]>>j)&1!=(b[i]>>j)&1 for i in range(n)):
    print(-1)
    exit()
  c+=1<<j
if c>0:
  print(c)
else:
  print(1<<len(bin(a[-1])[2:]))
0