Submission #7132575
Source Code Expand
# code-festival-2016-qualaC - 次のアルファベット / Next Letter from string import ascii_lowercase as abc def main(): S = input().rstrip() K = int(input()) N, MOD = len(S), 26 # dist[c] := distance to "a" through "z" dist = {c: 26 - i for i, c in enumerate(abc)} dist["a"] = 0 A = [dist[i] for i in S] for i in range(N): if A[i] and A[i] <= K: # A[i] -> "a" if possible A[i], K = 0, K - A[i] A[-1] = (A[-1] - K) % MOD # use the remaining K on A[-1] rest = {v: k for k, v in dist.items()} ans = [rest[i] for i in A] # restore dist to chr print(*ans, sep="") if __name__ == "__main__": main()
Submission Info
Submission Time | |
---|---|
Task | C - Next Letter |
User | solzard |
Language | Python (3.4.3) |
Score | 400 |
Code Size | 699 Byte |
Status | AC |
Exec Time | 83 ms |
Memory | 8476 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 24 ms | 3764 KB |
0_01.txt | AC | 23 ms | 3772 KB |
0_02.txt | AC | 24 ms | 3764 KB |
1_00.txt | AC | 24 ms | 3764 KB |
1_01.txt | AC | 24 ms | 3764 KB |
1_02.txt | AC | 24 ms | 3764 KB |
1_03.txt | AC | 24 ms | 3768 KB |
1_04.txt | AC | 24 ms | 3764 KB |
1_05.txt | AC | 24 ms | 3764 KB |
1_06.txt | AC | 65 ms | 8308 KB |
1_07.txt | AC | 76 ms | 8308 KB |
1_08.txt | AC | 70 ms | 8472 KB |
1_09.txt | AC | 67 ms | 8176 KB |
1_10.txt | AC | 69 ms | 8304 KB |
1_11.txt | AC | 68 ms | 8180 KB |
1_12.txt | AC | 66 ms | 8180 KB |
1_13.txt | AC | 66 ms | 8052 KB |
1_14.txt | AC | 73 ms | 8340 KB |
1_15.txt | AC | 74 ms | 8476 KB |
1_16.txt | AC | 74 ms | 8476 KB |
1_17.txt | AC | 75 ms | 8468 KB |
1_18.txt | AC | 74 ms | 8472 KB |
1_19.txt | AC | 75 ms | 8304 KB |
1_20.txt | AC | 83 ms | 8056 KB |
1_21.txt | AC | 75 ms | 8312 KB |
1_22.txt | AC | 75 ms | 8472 KB |
1_23.txt | AC | 74 ms | 8344 KB |