結果
問題 |
No.197 手品
|
ユーザー |
|
提出日時 | 2023-07-30 22:14:55 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 74 ms / 1,000 ms |
コード長 | 1,284 bytes |
コンパイル時間 | 9,744 ms |
コンパイル使用メモリ | 191,888 KB |
実行使用メモリ | 31,104 KB |
最終ジャッジ日時 | 2024-10-09 17:13:46 |
合計ジャッジ時間 | 14,699 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (282 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
let sBefore = stdin.ReadLine () let n = stdin.ReadLine () |> int let sAfter = stdin.ReadLine () let stateArray = [| "xxx" "xxo" "xox" "xoo" "oxx" "oxo" "oox" "ooo" |] let rec next (arr: bool array) count = if count = 0 then arr else let a = Array.replicate 8 false for i in 0..arr.Length-1 do if arr.[i] then let index1, index2 = match i with | 0 -> 0, 0 | 1 -> 1, 2 | 2 -> 4, 1 | 3 -> 5, 3 | 4 -> 2, 4 | 5 -> 3, 6 | 6 -> 6, 5 | _ -> 7, 7 a.[index1] <- true a.[index2] <- true next a (count-1) let firstState = Array.replicate 8 false firstState.[Array.findIndex ((=)sBefore) stateArray] <- true if n >= 2 then if Seq.sort sBefore |> Seq.toArray <> (Seq.sort sAfter |> Seq.toArray) then printfn "SUCCESS" else printfn "FAILURE" else next firstState n |> Array.get <| (Array.findIndex ((=)sAfter) stateArray) |> (fun x -> printfn "%s" (if x then "FAILURE" else "SUCCESS"))