結果

問題 No.987 N×Mマス計算(基本)
コンテスト
ユーザー tanson
提出日時 2025-12-19 03:54:52
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,190 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,970 ms
コンパイル使用メモリ 689,784 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-19 03:54:59
合計ジャッジ時間 4,773 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

fun readInt () =
    valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)

fun readLargeInt () =
    valOf (TextIO.scanStream (LargeInt.scan StringCvt.DEC) TextIO.stdIn)

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


exception BadInput
fun printAnsAux _ _ [] = []
  | printAnsAux "+" a (b :: bt) = LargeInt.toString (a + b) ::
                                  printAnsAux "+" a bt
  | printAnsAux "*" a (b :: bt) = LargeInt.toString (a * b) ::
                                  printAnsAux "*" a bt
  | printAnsAux _ _ _ = raise BadInput 


fun printAns _ [] _ = ignore ()
  | printAns operation (a :: at) b_s =
    (
      print ((String.concatWith " " (printAnsAux operation a b_s)) ^ "\n");
      printAns operation at b_s
    )


val () =
    let
        val n = readInt ()
        val m = readInt ()
        val operation = readStr ()
        val b_s = List.tabulate (m, fn _ => readLargeInt ())
        val a_s = List.tabulate (n, fn _ => readLargeInt ())
    in
        printAns operation a_s b_s
    end
0