Submission #6439561
Source Code Expand
S = input() K = int(input()) L = len(S) dp = [{a: 0 for a in map(chr, range(ord('a'), ord('z')+1))} for _ in range(L+1)] dp[1][S[-1]] = 1 cum = 0 for i in range(2,L+1): s = S[-i] dp[i][s] = 1 for abc in map(chr, range(ord('a'), ord('z')+1)): dp[i][abc] += dp[i-1][abc] if dp[i-1].get(abc): dp[i][s] += dp[i-1][abc] dp[i][s] -= dp[i-1][s] cum += dp[i][s] - 1 ans = '' if cum >= K: cnt = K pos = 0 while cnt > 0 and pos < L: for abc in map(chr, range(ord('a'), ord('z')+1)): if cnt - dp[-pos-1][abc] > 0: cnt -= dp[-pos-1][abc] else: ans += abc pos = S.find(abc, pos) + 1 cnt -= 1 break print(ans or 'Eel')
Submission Info
Submission Time | |
---|---|
Task | G - 辞書順 |
User | qython |
Language | PyPy3 (2.4.0) |
Score | 0 |
Code Size | 814 Byte |
Status | TLE |
Exec Time | 2178 ms |
Memory | 1193412 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 4 | ||||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | TLE | 2178 ms | 1193412 KB |
01 | AC | 416 ms | 107100 KB |
02 | AC | 165 ms | 38256 KB |
90 | AC | 164 ms | 38256 KB |
91 | AC | 166 ms | 38256 KB |