結果
| 問題 |
No.3290 Encrypt Failed, but Decrypt Succeeded
|
| コンテスト | |
| ユーザー |
nikoro256
|
| 提出日時 | 2025-10-03 22:05:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 709 bytes |
| コンパイル時間 | 369 ms |
| コンパイル使用メモリ | 82,820 KB |
| 実行使用メモリ | 107,864 KB |
| 最終ジャッジ日時 | 2025-10-03 22:05:06 |
| 合計ジャッジ時間 | 3,994 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 RE * 4 |
ソースコード
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
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]))
nikoro256