結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
sue_charo
|
| 提出日時 | 2017-06-30 23:25:31 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,843 bytes |
| コンパイル時間 | 223 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 17,172 KB |
| 最終ジャッジ日時 | 2024-10-04 21:32:10 |
| 合計ジャッジ時間 | 3,838 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | RE * 2 TLE * 1 |
ソースコード
# 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 RepresentsInt(s):
try:
int(s)
return True
except ValueError:
return False
def solve(T, test):
ans = []
for t in test:
l_ind = None
head_ind = None
for ind, char in enumerate(t):
if RepresentsInt(char):
if head_ind is None:
head_ind = ind
else:
continue
else:
if head_ind is None:
continue
else:
l_ind = (head_ind, ind - 1)
head_ind = None
else:
if head_ind is not None:
l_ind = (head_ind, len(t) - 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()
sue_charo