結果
| 問題 | No.3290 Encrypt Failed, but Decrypt Succeeded | 
| コンテスト | |
| ユーザー |  nikoro256 | 
| 提出日時 | 2025-10-03 22:08:52 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 118 ms / 2,000 ms | 
| コード長 | 726 bytes | 
| コンパイル時間 | 238 ms | 
| コンパイル使用メモリ | 82,044 KB | 
| 実行使用メモリ | 107,904 KB | 
| 最終ジャッジ日時 | 2025-10-03 22:08:57 | 
| 合計ジャッジ時間 | 4,027 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 | 
ソースコード
N,K=map(int,input().split())
t = input()
inf = 10**20
dp = [0 for _ in range(N+1)]
dp[-1] = 1
for i in range(N-1,-1,-1):
    if t[i] == "0":
        continue
    if i+2<=N and int(t[i]+t[i+1])<=26:
        dp[i] += dp[i+2]
    dp[i] += dp[i+1]
    dp[i] = min(dp[i],inf)
# 最初から決める
i = 0
ans=[]
while i < N:
    if i+2 <= N and t[i+1] == "0":
        ans.append(int(t[i]+t[i+1]))
        i+=2
        continue
    if i+2<=N and int(t[i]+t[i+1])<=26:
        if dp[i+1] < K:
            K-=dp[i+1]
            ans.append(int(t[i]+t[i+1]))
            i+=2
        else:
            ans.append(int(t[i]))
            i+=1
    else:
        ans.append(int(t[i]))
        i+=1
print("".join([chr(96+a) for a in ans]))
            
            
            
        