結果

問題 No.539 インクリメント
ユーザー Ikazuchis_diaryIkazuchis_diary
提出日時 2017-07-04 21:58:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 15,056 KB
最終ジャッジ日時 2024-04-15 16:18:34
合計ジャッジ時間 1,246 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import re

T = int(input())
S = []
for i in range(T):
    S.append(input())

for s in S:
    pattern = r'\d+'
    iterator = re.finditer(pattern, s)
    match = []
    longest = 0
    for i in iterator:
        if len(i.group()) > longest:
            match = []
            match.append(i)
            longest = len(i.group())
        elif len(i.group()) == longest:
            match.append(i)
    if len(match) == 0:
        print(s)
        next
    ans = ''
    for i in range(len(match)):
        if i == 0:
            ans += s[:match[i].start()]
        ans += ('%0' + str(len(match[i].group())) + 'd') % (int(match[i].group()) + 1)
        if i == len(match):
            ans += s[match[i].end():match[i+1].start()]
        else:
            ans += s[match[i].end():]
    print(ans)
0