結果
問題 | 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 = 0 f = adj for e in E: if n ^ e < n: n ^= e ret += f f = 0 else: ret += f ^ 1 f = 1 ret += f return 100 if n else ret N = int(input()) A = [int(a) for a in input().split()] m = (1 << 60) - 1 s = m E = [] for a in A[1:][::-1]: t = s & a for e in E: t = min(t, t ^ e) if t: E.append(t) s &= a ^ m s &= 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 <= 200000 assert len(A) == N for a in A: assert 0 <= a < 1 << 60 assert 1 <= Q <= 200000 assert len(L) == Q for b in L: assert 0 <= b < 1 << 60