結果
| 問題 | 
                            No.197 手品
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-07-30 22:12:26 | 
| 言語 | F#  (F# 4.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,252 bytes | 
| コンパイル時間 | 15,210 ms | 
| コンパイル使用メモリ | 193,372 KB | 
| 実行使用メモリ | 30,848 KB | 
| 最終ジャッジ日時 | 2024-10-09 17:11:02 | 
| 合計ジャッジ時間 | 14,017 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 2 | 
| other | AC * 21 WA * 22 | 
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (290 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.sort sAfter 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"))