結果

問題 No.3290 Encrypt Failed, but Decrypt Succeeded
ユーザー timi
提出日時 2025-10-05 10:43:21
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 744 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 848,680 KB
最終ジャッジ日時 2025-10-05 10:43:30
合計ジャッジ時間 4,455 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 MLE * 1 -- * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int, input().split())
S=input()
dp=[1]
for i in range(N-1,-1,-1):
  if i==N-1:
    if S[i]=='0':
      dp.append(0)
    else:
      dp.append(1)
  else:
    dp.append(0)
    if S[i]!='0':
      dp[-1]+=dp[-2]
    else:
      continue
    s,t=int(S[i]),int(S[i+1])
    if s*10+t<=26:
      dp[-1]+=dp[-3]
  

dp=dp[::-1]
dp.append(0)
T='!abcdefghijklmnopqrstuvwxyz'
ans=[]
now=0
while now<N:
  x=dp[now+1]
  if x==0:
    ans.append(T[int(S[now])])
    now+=1
  elif x<K:
    a,b=S[now],S[now+1]
    ans.append(T[int(a+b)])
    now+=2
    K-=x
  else:
    a=S[now]
    if int(a)==0:
      if ans[-1]=='b':
        ans[-1]='t'
      if ans[-1]=='a':
        ans[-1]='j'
    else:
      ans.append(T[int(a)])
    now+=1
print(''.join(ans))
0