結果
問題 | No.1296 OR or NOR |
ユーザー |
![]() |
提出日時 | 2020-06-25 23:50:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 536 ms / 3,000 ms |
コード長 | 762 bytes |
コンパイル時間 | 738 ms |
コンパイル使用メモリ | 82,208 KB |
実行使用メモリ | 122,136 KB |
最終ジャッジ日時 | 2024-06-11 20:56:40 |
合計ジャッジ時間 | 12,779 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 33 |
ソースコード
def calc(n, adj=0):ret = 0f = adjfor e in E:if n ^ e < n:n ^= eret += ff = 0else:ret += f ^ 1f = 1ret += freturn 100 if n else retN = int(input())A = [int(a) for a in input().split()]m = (1 << 60) - 1s = mE = []for a in A[1:][::-1]:t = s & afor e in E:t = min(t, t ^ e)if t: E.append(t)s &= a ^ ms &= A[0]Q = int(input())L = [int(a) for a in input().split()]for b in L:t = min(calc(b ^ s), calc(b ^ s ^ m, 1))print(-1 if t > 99 else t)assert 1 <= N <= 200000assert len(A) == Nfor a in A:assert 0 <= a < 1 << 60assert 1 <= Q <= 200000assert len(L) == Qfor b in L:assert 0 <= b < 1 << 60