結果

問題 No.539 インクリメント
ユーザー kohei2019kohei2019
提出日時 2022-02-08 20:42:54
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,039 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 178,540 KB
最終ジャッジ日時 2023-09-05 21:04:11
合計ジャッジ時間 2,603 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

T = int(input())

for i in range(T):
    f1 = False
    f2 = False
    t = input()
    n = len(t)
    b = []
    num = []
    a = []
    for j in range(n-1,-1,-1):
        if not f2:
            if f1 == False and t[j].isnumeric():
                num.append(t[j])
                f1 = True
            elif f1 == False and not t[j].isnumeric():
                b.append(t[j])
            elif f1 and t[j].isnumeric():
                num.append(t[j])
            else:
                a.append(t[j])
                f2 = True
        else:
            a.append(t[j])
    b.reverse()
    a.reverse()
    if not num:
        print(*b,sep='')
    else:
        c = []
        f = True
        for s in num:
            if f and s=='9':
                c.append('0')
                continue
            elif f:
                c.append(str(int(s)+1))
                f = False
            else:
                c.append(s)
        if f:
            c.append('1')
        c.reverse()
        ans = a+c+b
        print(''.join(ans))
        

0