結果

問題 No.539 インクリメント
ユーザー sue_charosue_charo
提出日時 2017-06-30 23:58:57
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,263 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 104,012 KB
最終ジャッジ日時 2024-04-15 07:15:52
合計ジャッジ時間 1,364 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

# 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):
    ascii_set_no_num = set()
    for i in range(32, 48):
        ascii_set_no_num.add(chr(i))
    for i in range(58, 127):
        ascii_set_no_num.add(chr(i))

    ascii_set_num = set()
    for i in range(48, 58):
        ascii_set_num.add(chr(i))

    ans = []
    for t in test:
        set_t = set(list(t))
        set_check_all_num = ascii_set_no_num & set_t
        set_check_all_str = ascii_set_num & set_t

        if len(set_check_all_num) == 0:
            l_ind = (0, len(t))
        elif len(set_check_all_str) == 0:
            ans.append(t)
            continue
        else:
            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)

        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()
0