結果
| 問題 |
No.3290 Encrypt Failed, but Decrypt Succeeded
|
| コンテスト | |
| ユーザー |
nikoro256
|
| 提出日時 | 2025-10-03 22:04:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 682 bytes |
| コンパイル時間 | 378 ms |
| コンパイル使用メモリ | 82,084 KB |
| 実行使用メモリ | 848,844 KB |
| 最終ジャッジ日時 | 2025-10-03 22:04:04 |
| 合計ジャッジ時間 | 3,920 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 RE * 1 MLE * 1 -- * 16 |
ソースコード
N,K=map(int,input().split())
t = input()
inf = 10**18
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]
# 最初から決める
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