結果

問題 No.1296 OR or NOR
ユーザー googol_S0googol_S0
提出日時 2020-11-20 22:29:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,406 ms / 3,000 ms
コード長 630 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 134,812 KB
最終ジャッジ日時 2023-09-30 19:35:36
合計ジャッジ時間 30,954 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,224 KB
testcase_01 AC 73 ms
71,296 KB
testcase_02 AC 631 ms
118,248 KB
testcase_03 AC 639 ms
122,352 KB
testcase_04 AC 1,196 ms
125,780 KB
testcase_05 AC 1,012 ms
118,596 KB
testcase_06 AC 584 ms
133,204 KB
testcase_07 AC 576 ms
132,808 KB
testcase_08 AC 528 ms
132,616 KB
testcase_09 AC 654 ms
125,660 KB
testcase_10 AC 669 ms
125,616 KB
testcase_11 AC 671 ms
118,076 KB
testcase_12 AC 633 ms
116,940 KB
testcase_13 AC 655 ms
114,144 KB
testcase_14 AC 2,406 ms
126,292 KB
testcase_15 AC 1,389 ms
118,228 KB
testcase_16 AC 1,203 ms
118,300 KB
testcase_17 AC 576 ms
133,032 KB
testcase_18 AC 589 ms
134,812 KB
testcase_19 AC 602 ms
133,024 KB
testcase_20 AC 528 ms
115,076 KB
testcase_21 AC 510 ms
115,536 KB
testcase_22 AC 438 ms
115,524 KB
testcase_23 AC 446 ms
115,720 KB
testcase_24 AC 467 ms
114,740 KB
testcase_25 AC 472 ms
114,952 KB
testcase_26 AC 516 ms
114,896 KB
testcase_27 AC 525 ms
115,072 KB
testcase_28 AC 507 ms
115,788 KB
testcase_29 AC 485 ms
114,204 KB
testcase_30 AC 1,606 ms
118,088 KB
testcase_31 AC 1,613 ms
118,140 KB
testcase_32 AC 1,617 ms
118,172 KB
testcase_33 AC 808 ms
116,064 KB
testcase_34 AC 810 ms
116,180 KB
権限があれば一括ダウンロードができます

ソースコード

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):
      Y.add(X[j])
    else:
      Z.add(X[j])
  if len(Y&Z):
    print(-1)
  elif ((0 in Y)and(-1 in Y))or((0 in Z)and(-1 in Z)):
    print(-1)
  else:
    V=sorted(Y|Z,reverse=True)
    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