結果
| 問題 | No.3290 Encrypt Failed, but Decrypt Succeeded | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-10-05 20:20:48 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 132 ms / 2,000 ms | 
| コード長 | 1,139 bytes | 
| コンパイル時間 | 431 ms | 
| コンパイル使用メモリ | 82,664 KB | 
| 実行使用メモリ | 105,784 KB | 
| 最終ジャッジ日時 | 2025-10-05 20:20:53 | 
| 合計ジャッジ時間 | 4,807 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 | 
ソースコード
from string import ascii_lowercase
import sys
import os
IS_LOCAL = os.environ.get("LOCAL") == "true"
def debug(*args, sep=" ", end="\n", flush=False) -> None:
    if IS_LOCAL:
        print(*args, sep=sep, end=end, file=sys.stderr, flush=flush)
def yn(flg: bool) -> bool:
    print('Yes' if flg else 'No')
    return flg
def main():
    readline = sys.stdin.readline
    inf = 10**18 + 9
    N, K = map(int, readline().split())
    K -= 1
    S = readline().strip()
    dp = [0] * (N + 1)
    dp[N] = 1
    for i in range(N - 1, -1, -1):
        c = int(S[i])
        if c == 0:
            continue
        dp[i] = dp[i + 1]
        if c <= 2 and i + 1 < N and 1 <= int(S[i:i + 2]) <= 26:
            dp[i] += dp[i + 2]
        dp[i] = min(dp[i], inf)
    debug(dp)
    ans = []
    i = 0
    while i < N:
        c = int(S[i])
        if c <= 2 and i + 1 < N and 1 <= int(S[i:i + 2]) <= 26 and K >= dp[i + 1]:
            K -= dp[i + 1]
            c = int(S[i:i + 2])
            i += 2
        else:
            i += 1
        ans.append(ascii_lowercase[c - 1])
    print("".join(ans))
if __name__ == "__main__":
    main()
            
            
            
        