結果

問題 No.1296 OR or NOR
ユーザー googol_S0googol_S0
提出日時 2020-11-20 22:29:22
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 2,518 ms / 3,000 ms
コード長 630 bytes
コンパイル時間 761 ms
使用メモリ 146,064 KB
最終ジャッジ日時 2023-02-23 19:02:46
合計ジャッジ時間 34,111 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 74 ms
75,764 KB
testcase_01 AC 75 ms
75,776 KB
testcase_02 AC 684 ms
123,512 KB
testcase_03 AC 672 ms
120,600 KB
testcase_04 AC 1,192 ms
121,668 KB
testcase_05 AC 1,060 ms
126,504 KB
testcase_06 AC 649 ms
141,408 KB
testcase_07 AC 649 ms
139,516 KB
testcase_08 AC 588 ms
146,064 KB
testcase_09 AC 694 ms
131,644 KB
testcase_10 AC 722 ms
132,664 KB
testcase_11 AC 691 ms
127,332 KB
testcase_12 AC 688 ms
124,612 KB
testcase_13 AC 747 ms
135,972 KB
testcase_14 AC 2,518 ms
130,076 KB
testcase_15 AC 1,402 ms
126,112 KB
testcase_16 AC 1,200 ms
122,544 KB
testcase_17 AC 652 ms
137,348 KB
testcase_18 AC 650 ms
138,772 KB
testcase_19 AC 674 ms
138,700 KB
testcase_20 AC 596 ms
119,956 KB
testcase_21 AC 586 ms
120,272 KB
testcase_22 AC 498 ms
120,548 KB
testcase_23 AC 495 ms
117,316 KB
testcase_24 AC 510 ms
120,000 KB
testcase_25 AC 504 ms
116,756 KB
testcase_26 AC 566 ms
120,084 KB
testcase_27 AC 574 ms
120,256 KB
testcase_28 AC 561 ms
120,480 KB
testcase_29 AC 532 ms
120,236 KB
testcase_30 AC 1,607 ms
126,472 KB
testcase_31 AC 1,615 ms
126,460 KB
testcase_32 AC 1,604 ms
126,280 KB
testcase_33 AC 847 ms
118,736 KB
testcase_34 AC 846 ms
118,764 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