結果
| 問題 | No.539 インクリメント |
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2021-01-17 22:50:53 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,034 bytes |
| 記録 | |
| コンパイル時間 | 198 ms |
| コンパイル使用メモリ | 82,096 KB |
| 実行使用メモリ | 130,304 KB |
| 最終ジャッジ日時 | 2024-11-30 04:46:03 |
| 合計ジャッジ時間 | 2,337 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 1 WA * 1 MLE * 1 |
ソースコード
from string import digits
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
T = int(input())
digits = set(list(digits))
for _ in range(T):
S = input().rstrip()
N = len(S)
i = N - 1
prev = []
num = []
while i:
if not S[i] in digits:
prev.append(S[i])
i -= 1
else:
if S[i] == "9":
up = 1
num.append("0")
else:
up = 0
num.append(str(int(S[i])+1))
i -= 1
while i and S[i] in digits:
if up:
if S[i] == "9":
num.append("0")
else:
up = 0
num.append(str(int(S[i]) + 1))
else:
num.append(S[i])
i -= 1
if up:
num.append("1")
break
print(S[:i+1], end="")
print("".join(num[::-1]), end="")
print("".join(prev[::-1]))
tktk_snsn