結果
| 問題 | No.222 引き算と足し算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-14 00:59:14 |
| 言語 | Standard ML (MLton 20241230) |
| 結果 |
AC
不安定
|
| 実行時間 | 0 ms / 1,000 ms |
| + 699µs | |
| コード長 | 873 bytes |
| 記録 | |
| コンパイル時間 | 6,029 ms |
| コンパイル使用メモリ | 705,288 KB |
| 実行使用メモリ | 9,904 KB |
| 最終ジャッジ日時 | 2026-09-26 19:16:41 |
| 合計ジャッジ時間 | 8,014 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
コンパイルメッセージ
Warning: main.sml 13.5-16.28.
Function is not exhaustive.
missing pattern: (_, nil)
in: fun findOpIndex i (#"+" :: _) = i ... pIndex (i + 1) rest)
ソースコード
fun readStr () =
let
fun scan reader stream = SOME (StringCvt.splitl (not o Char.isSpace) reader (StringCvt.skipWS reader stream))
in
valOf (TextIO.scanStream scan TextIO.stdIn)
end
fun intString n =
if 0 <= n
then Int.toString n
else "-" ^ Int.toString (abs n)
fun findOpIndex i (#"+" :: _) = i
| findOpIndex i (#"-" :: _) = i
| findOpIndex i (_ :: rest) =
findOpIndex (i + 1) rest
val () =
let
val s = readStr ()
val opIndex = findOpIndex 1 (List.tl (String.explode s))
val x = valOf (Int.fromString (String.substring (s, 0, opIndex)))
val y = valOf (Int.fromString (String.extract (s, opIndex + 1, NONE)))
val opChar = String.sub (s, opIndex)
val ans = if opChar = #"+" then x - y
else x + y
in
print (intString ans ^ "\n")
end