結果

問題 No.2397 ω冪
ユーザー 👑 testestest
提出日時 2022-11-18 20:01:09
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 779 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-09-20 00:55:39
合計ジャッジ時間 5,635 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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:
      return check(aa,bb,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(bin(cnt)[2:])
      cnt=0
  ans=[]
  for s in temp[::-1]:
    while len(ans) and check(ans[-1],s,f):
      ans.pop()
    ans.append(s)
  return ans

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