結果

問題 No.264 じゃんけん
ユーザー tanson
提出日時 2025-07-02 19:00:30
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 982 bytes
コンパイル時間 4,685 ms
コンパイル使用メモリ 687,288 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-02 19:00:36
合計ジャッジ時間 5,635 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

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

datatype rock_paper_scissors = Rock | Paper | Scissors
datatype result = Won | Lost | Drew

exception WrongInput
fun intToRockPaperScissors 0 = Rock
  | intToRockPaperScissors 1 = Scissors
  | intToRockPaperScissors 2 = Paper
  | intToRockPaperScissors _ = raise WrongInput 

fun findResult Rock Rock = Drew
  | findResult Rock Scissors = Won
  | findResult Rock Paper = Lost
  | findResult Scissors Rock = Lost
  | findResult Scissors Scissors = Drew
  | findResult Scissors Paper = Won
  | findResult Paper Rock = Won
  | findResult Paper Scissors = Lost
  | findResult Paper Paper = Drew

fun resultToString Won = "Won"
  | resultToString Lost = "Lost"
  | resultToString Drew = "Drew"  

val () =
    let
        val n = readInt ()
        val k = readInt ()
        val ans = resultToString (findResult (intToRockPaperScissors n) (intToRockPaperScissors k))
    in
        print ans
    end
0