Submission #6439476
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 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] ans = '' if sum(dp[-1].values()) >= 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 | Python (3.4.3) |
Score | 0 |
Code Size | 797 Byte |
Status | TLE |
Exec Time | 2149 ms |
Memory | 741048 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 | 2149 ms | 741048 KB |
01 | MLE | 719 ms | 286212 KB |
02 | AC | 17 ms | 3064 KB |
90 | AC | 17 ms | 3064 KB |
91 | AC | 17 ms | 3064 KB |