結果
| 問題 |
No.3290 Encrypt Failed, but Decrypt Succeeded
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-03 22:07:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 958 ms / 2,000 ms |
| コード長 | 705 bytes |
| コンパイル時間 | 341 ms |
| コンパイル使用メモリ | 82,240 KB |
| 実行使用メモリ | 400,996 KB |
| 最終ジャッジ日時 | 2025-10-03 22:08:02 |
| 合計ジャッジ時間 | 13,417 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
import sys
sys.setrecursionlimit(int(1e9))
n, k = map(int, input().split())
t = list(map(int, input()))
cnt = [-1] * (n + 1)
def solve(i):
if cnt[i] != -1:
return cnt[i]
if i == n:
cnt[i] = 1
return 1
if t[i] == 0:
cnt[i] = 0
return 0
cnt[i] = solve(i + 1)
if i != n - 1 and t[i] * 10 + t[i + 1] <= 26:
cnt[i] += solve(i + 2)
return min(10**18 + 2525, cnt[i])
solve(0)
p = 0
k -= 1
ans = []
while p < n:
if k < cnt[p + 1]:
ans.append(chr(96 + t[p]))
p += 1
else:
c = t[p] * 10 + t[p + 1]
ans.append(chr(96 + c))
k -= cnt[p + 1]
p += 2
assert k == 0
print(*ans, sep="")