結果

問題 No.482 あなたの名は
ユーザー ichibanshiboriichibanshibori
提出日時 2017-02-11 01:37:01
言語 F#
(F# 4.0)
結果
RE  
実行時間 -
コード長 1,270 bytes
コンパイル時間 4,355 ms
コンパイル使用メモリ 155,220 KB
実行使用メモリ 48,124 KB
最終ジャッジ日時 2023-08-28 12:41:13
合計ジャッジ時間 9,578 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
22,876 KB
testcase_01 AC 80 ms
20,772 KB
testcase_02 AC 82 ms
24,712 KB
testcase_03 AC 81 ms
24,812 KB
testcase_04 AC 82 ms
22,784 KB
testcase_05 AC 81 ms
22,872 KB
testcase_06 AC 81 ms
22,700 KB
testcase_07 AC 88 ms
22,988 KB
testcase_08 AC 88 ms
23,104 KB
testcase_09 AC 91 ms
22,892 KB
testcase_10 AC 90 ms
22,920 KB
testcase_11 AC 90 ms
24,948 KB
testcase_12 AC 89 ms
25,036 KB
testcase_13 AC 89 ms
22,796 KB
testcase_14 AC 88 ms
22,980 KB
testcase_15 AC 204 ms
44,040 KB
testcase_16 AC 205 ms
44,012 KB
testcase_17 AC 204 ms
46,060 KB
testcase_18 AC 202 ms
46,132 KB
testcase_19 AC 203 ms
46,260 KB
testcase_20 AC 204 ms
44,064 KB
testcase_21 AC 202 ms
48,124 KB
testcase_22 AC 203 ms
46,052 KB
testcase_23 AC 203 ms
46,080 KB
testcase_24 AC 203 ms
44,108 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let solve k darr =
    let len_darr = Array.length darr
    let chk_arr = Array.create len_darr false
    
    let rec get_len_loop start current result =
        chk_arr.[current] <- true

        let next = darr.[current]
        let result = current::result

        //eprintfn "get_len_loop: %A" (start, current, result)

        if next = start then (List.length result) - 1
        else
            get_len_loop start next result
    
    let rec get_len_loop_sum idx result =
        //eprintfn "get_len_loop_sum: %A" (idx, result)

        if idx >= len_darr then result
        else
            if chk_arr.[idx] then get_len_loop_sum (idx + 1) result
            else
                let len_loop = get_len_loop idx idx []
                get_len_loop_sum (idx + 1) (result + len_loop)

    let len_loop = get_len_loop_sum 0 0

    k >= len_loop && (k - len_loop) % 2 = 0

let () =
    let _, k = stdin.ReadLine()
               |> fun s -> s.Split()
               |> Array.map int
               |> fun arr -> (arr.[0], arr.[1])
    let darr = stdin.ReadLine()
               |> fun s -> s.Split()
               |> Array.map int
               |> Array.map (( + ) -1)
    
    solve k darr
    |> function | true -> "YES" | false -> "NO"
    |> printfn "%s"
0