結果

問題 No.1296 OR or NOR
ユーザー googol_S0googol_S0
提出日時 2020-11-20 22:11:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 560 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 85,944 KB
実行使用メモリ 133,816 KB
最終ジャッジ日時 2023-09-30 19:21:56
合計ジャッジ時間 30,270 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,044 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 509 ms
131,772 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 569 ms
132,208 KB
testcase_18 AC 582 ms
131,988 KB
testcase_19 AC 598 ms
132,212 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 422 ms
114,328 KB
testcase_23 AC 433 ms
114,980 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 457 ms
113,504 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
B=list(map(int,input().split()))
X=[-1]*60
for i in range(60):
  for j in range(N-1,-1,-1):
    if A[j]&(1<<i):
      X[i]=j
      break
for i in range(Q):
  Y,Z=set(),set()
  for j in range(60):
    if (B[i]&(1<<j))^(X[j]==1):
      Y.add(X[j])
    else:
      Z.add(X[j])
  if len(Y&Z):
    print(-1)
  else:
    V=sorted(Y|Z)
    P=0
    for j in range(len(V)):
      if V[j] in Y:
        if (P&1)^(V[j]==-1):
          P+=1
      else:
        if (P&1)^(V[j]!=-1):
          P+=1
    print(P)
0