結果
問題 | No.539 インクリメント |
ユーザー |
|
提出日時 | 2019-01-26 13:26:56 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 1,207 bytes |
コンパイル時間 | 3,145 ms |
コンパイル使用メモリ | 65,528 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 10:54:04 |
合計ジャッジ時間 | 4,289 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
import sequtils,algorithm,strutilstemplate times*(n:int,body) = (for _ in 0..<n: body)proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}proc scan(): int =while true:let k = getchar_unlocked()if k < '0': breakresult = 10 * result + k.ord - '0'.ordproc parse(): seq[tuple[str:string,isNum:bool]] =result = @[]var current = ""var isNum = falsewhile true:let k = getchar_unlocked()if k.ord < 32 or k.ord > 126 :result &= (current,isNum)returnlet kIsNum = k >= '0' and k <= '9'if isNum xor kIsNum and current != "":result &= (current,isNum)current = ""current &= kisNum = kIsNumproc add1(S:string):string =result = ""var ch = 1for i in (S.len-1).countdown(0):let c = S[i].ord - '0'.ordlet d = c + chif d < 10 :ch = 0result &= ('0'.ord + d).chrelse:ch = 1result &= ('0'.ord + d mod 10).chrif ch > 0:result &= ('0'.ord + ch).chrresult.reverse()scan().times:var P = parse()for i in (P.len()-1).countdown(0):if not P[i].isNum : continueP[i].str = P[i].str.add1()breakecho P.mapIt(it.str).join("")