結果

問題 No.88 次はどっちだ
ユーザー taktak
提出日時 2018-07-31 01:18:59
言語 F#
(F# 4.0)
結果
AC  
実行時間 79 ms / 5,000 ms
コード長 980 bytes
コンパイル時間 4,205 ms
コンパイル使用メモリ 167,284 KB
実行使用メモリ 24,988 KB
最終ジャッジ日時 2023-10-13 11:37:24
合計ジャッジ時間 5,939 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
22,872 KB
testcase_01 AC 75 ms
22,952 KB
testcase_02 AC 76 ms
22,860 KB
testcase_03 AC 75 ms
22,824 KB
testcase_04 AC 78 ms
24,988 KB
testcase_05 AC 76 ms
24,940 KB
testcase_06 AC 74 ms
22,864 KB
testcase_07 AC 77 ms
24,972 KB
testcase_08 AC 79 ms
20,928 KB
testcase_09 AC 77 ms
22,788 KB
testcase_10 AC 76 ms
23,028 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let R() = stdin.ReadLine()

type Turn = FstPlayer | SndPlayer
let (|Oda|Yukiko|) = function | x when x = "oda" -> Oda | _ -> Yukiko
let (|Odd|Eve|) n  = match n % 2 with | 1 -> Odd | _ -> Eve

let playerName fstMove (turn:Turn) =
    match fstMove, turn with
    | Oda, FstPlayer 
    | Yukiko, SndPlayer 
        -> "oda"
    | _ -> "yukiko"
    
let judge (board:string[]) =
    let charaDist=
        board
        |> Array.map(fun x -> x.ToCharArray())
        |> Array.concat
        |> Array.countBy(fun x -> x)
        |> Map.ofArray
    let blackNum = charaDist |> Map.find 'b'
    let whiteNum = charaDist |> Map.find 'w'
    match abs(blackNum - whiteNum) with
    | Eve -> Turn.FstPlayer 
    | Odd -> Turn.SndPlayer

[<EntryPoint>]
let main _ =
    let GRID_NUM = 8
    let S = R()
    let B = Array.init GRID_NUM (fun _ -> R())
    judge B
    |> function
        | FstPlayer as t -> playerName S t
        | SndPlayer as t -> playerName S t
    |> printfn "%s"
    0
0