結果

問題 No.1296 OR or NOR
ユーザー googol_S0googol_S0
提出日時 2020-11-20 21:59:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 135,020 KB
最終ジャッジ日時 2023-09-30 19:14:51
合計ジャッジ時間 31,289 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,276 KB
testcase_01 AC 72 ms
71,208 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 550 ms
133,956 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 573 ms
134,488 KB
testcase_18 AC 579 ms
134,384 KB
testcase_19 AC 593 ms
134,572 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 439 ms
115,356 KB
testcase_23 AC 446 ms
115,656 KB
testcase_24 AC 461 ms
114,856 KB
testcase_25 AC 467 ms
114,708 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 484 ms
114,052 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 748 ms
115,844 KB
testcase_34 AC 746 ms
115,724 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
O=[0]*(N+1)
for i in range(N):
  O[i+1]=O[i]|A[-i-1]
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)
  else:
    V=list(Y|Z)
    R,S=0,0
    for j in range(len(V)):
      if V[j]!=-1:
        if V[j] in Y:
          S=max(S,R+1)
        else:
          S+=1
          R=max(R,S)
    print(R)
0