結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-22 11:03:41 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 302 ms / 2,000 ms |
| コード長 | 1,159 bytes |
| コンパイル時間 | 245 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 17,172 KB |
| 最終ジャッジ日時 | 2024-12-23 14:16:28 |
| 合計ジャッジ時間 | 1,708 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
import re
def partsolve2(l):
l = list(l)
addone = False
started = False
n = 0
for i, c in enumerate(l[::-1]):
n = i
if 0x30 <= ord(c) <= 0x38:
l[len(l) - i - 1] = chr(ord(c) + 1)
addone = False
break
elif ord(c) == 0x39:
l[len(l) - i - 1] = "0"
addone = True
started = True
else:
if addone:
l.insert(len(l) - i, "1")
addone = False
if started:
break
if addone:
l.insert(len(l) - n - 1, "1")
return "".join(l)
def partsolve(l):
match_list = re.findall("[0-9]+", l)
if match_list:
last = match_list[-1]
size = len(last)
replace = ("{:0" + str(size) + "}").format(int(last) + 1)
data = re.sub(last[::-1], replace[::-1], l[::-1], count=1)
return data[::-1]
else:
return l
def solve(N, lines):
ret = []
for l in lines:
ret.append(partsolve2(l))
return ret
if __name__ == "__main__":
N = int(input())
[print(s) for s in solve(N, [input() for _ in range(N)])]