結果

問題 No.2397 ω冪
ユーザー 👑 testestesttestestest
提出日時 2022-11-18 19:58:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 738 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-09-20 00:54:09
合計ジャッジ時間 5,245 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(A,B,f):
  # return A<B
  AA=f(A)
  BB=f(B)
  for aa,bb in zip(AA,BB):
    if aa!=bb:
      a=bin(aa)[2:]
      b=bin(bb)[2:]
      return check(a,b,f)
  return len(AA)<len(BB)

def f(S):
  temp=[]
  cnt=0
  for c in S[::-1]:
    if c=='0':
      cnt+=1
    else:
      temp.append(cnt)
      cnt=0
  ans=[]
  for n in temp[::-1]:
    while len(ans) and check(bin(ans[-1])[2:],bin(n)[2:],f):
      ans.pop()
    ans.append(n)
  return ans

N=input()
M=input()
print("Yes" if check(N,M,f) else "No")
0