結果
問題 |
No.539 インクリメント
|
ユーザー |
![]() |
提出日時 | 2017-06-30 23:41:06 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,742 bytes |
コンパイル時間 | 140 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 17,292 KB |
最終ジャッジ日時 | 2024-10-04 21:45:50 |
合計ジャッジ時間 | 984 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 RE * 2 |
ソースコード
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} def read(): T = II() test = [str(input()) for __ in range(T)] return T, test def solve(T, test): ans = [] for t in test: back_ind = None l_ind = None for ind, char in enumerate(t[::-1]): if char.isdigit(): if back_ind is None: back_ind = ind else: continue else: if back_ind is None: continue else: l_ind = (len(t) - ind, len(t) - back_ind - 1) break else: if back_ind is not None: l_ind = (0, len(t) - back_ind - 1) if l_ind is None: ans.append(t) else: front_ind, back_ind = l_ind front_str = "".join(t[:front_ind]) num_str = "".join(t[front_ind:back_ind + 1]) back_str = "".join(t[back_ind + 1:]) len_num = len(num_str) num_leveled = str(int(num_str) + 1) if len_num > len(num_leveled): num_leveled = num_leveled.zfill(len_num) all_joined = front_str + num_leveled + back_str ans.append(all_joined) return ans def main(): params = read() ans = solve(*params) for a in ans: print(a) if __name__ == "__main__": main()