結果

問題 No.197 手品
ユーザー natoriusannatoriusan
提出日時 2023-07-30 22:14:55
言語 F#
(F# 4.0)
結果
AC  
実行時間 78 ms / 1,000 ms
コード長 1,284 bytes
コンパイル時間 11,440 ms
コンパイル使用メモリ 193,532 KB
実行使用メモリ 30,976 KB
最終ジャッジ日時 2024-04-17 23:29:18
合計ジャッジ時間 13,815 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
30,424 KB
testcase_01 AC 75 ms
30,848 KB
testcase_02 AC 76 ms
30,848 KB
testcase_03 AC 77 ms
30,720 KB
testcase_04 AC 74 ms
30,720 KB
testcase_05 AC 74 ms
30,584 KB
testcase_06 AC 72 ms
30,464 KB
testcase_07 AC 78 ms
30,328 KB
testcase_08 AC 74 ms
30,720 KB
testcase_09 AC 72 ms
30,464 KB
testcase_10 AC 73 ms
30,720 KB
testcase_11 AC 73 ms
30,720 KB
testcase_12 AC 73 ms
30,592 KB
testcase_13 AC 73 ms
30,720 KB
testcase_14 AC 73 ms
30,832 KB
testcase_15 AC 73 ms
30,720 KB
testcase_16 AC 74 ms
30,720 KB
testcase_17 AC 74 ms
30,848 KB
testcase_18 AC 74 ms
30,592 KB
testcase_19 AC 76 ms
30,584 KB
testcase_20 AC 74 ms
30,720 KB
testcase_21 AC 74 ms
30,720 KB
testcase_22 AC 74 ms
30,712 KB
testcase_23 AC 72 ms
30,592 KB
testcase_24 AC 71 ms
30,328 KB
testcase_25 AC 72 ms
30,464 KB
testcase_26 AC 78 ms
30,444 KB
testcase_27 AC 72 ms
30,328 KB
testcase_28 AC 73 ms
30,448 KB
testcase_29 AC 73 ms
30,720 KB
testcase_30 AC 72 ms
30,464 KB
testcase_31 AC 72 ms
30,848 KB
testcase_32 AC 72 ms
30,336 KB
testcase_33 AC 76 ms
30,336 KB
testcase_34 AC 72 ms
30,464 KB
testcase_35 AC 74 ms
30,848 KB
testcase_36 AC 74 ms
30,976 KB
testcase_37 AC 77 ms
30,572 KB
testcase_38 AC 71 ms
30,464 KB
testcase_39 AC 73 ms
30,464 KB
testcase_40 AC 71 ms
30,464 KB
testcase_41 AC 74 ms
30,720 KB
testcase_42 AC 71 ms
30,464 KB
testcase_43 AC 73 ms
30,976 KB
testcase_44 AC 73 ms
30,848 KB
testcase_45 AC 73 ms
30,572 KB
testcase_46 AC 74 ms
30,584 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (245 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/

ソースコード

diff #

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"))
0