結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
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:
    minind = 0
    maxind = 0
    before = False
    longest = ''
    see = ''
    nowminind = 0
    for i in range(len(s)):
        if s[i] in {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}:
            if not before:
                nowminind = i
                before = True
            see += s[i]
        else:
            if len(see) >= len(longest):
                longest = see
                minind = nowminind
                maxind = i
            see = ''
            before = False
    if see != '':
        if len(see) >= len(longest):
            longest = see
            minind = nowminind
            maxind = len(s)
            see = ''

    if len(longest) == 0:
        print(s)
        continue

    ans = s[:minind]
    ans += ('%0' + str(len(longest)) + 'd') % (int(longest) + 1)
    ans += s[maxind:]
    print(ans)
0