結果

問題 No.482 あなたの名は
ユーザー ichibanshiboriichibanshibori
提出日時 2017-02-11 01:44:00
言語 F#
(F# 4.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 1,298 bytes
コンパイル時間 3,730 ms
コンパイル使用メモリ 159,344 KB
実行使用メモリ 46,240 KB
最終ジャッジ日時 2023-08-28 16:19:14
合計ジャッジ時間 9,553 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
24,664 KB
testcase_01 AC 79 ms
24,852 KB
testcase_02 AC 79 ms
22,696 KB
testcase_03 AC 80 ms
20,744 KB
testcase_04 AC 80 ms
24,824 KB
testcase_05 AC 79 ms
22,744 KB
testcase_06 AC 80 ms
22,744 KB
testcase_07 AC 87 ms
24,928 KB
testcase_08 AC 88 ms
22,924 KB
testcase_09 AC 86 ms
24,956 KB
testcase_10 AC 87 ms
23,024 KB
testcase_11 AC 86 ms
25,100 KB
testcase_12 AC 87 ms
22,904 KB
testcase_13 AC 86 ms
23,004 KB
testcase_14 AC 87 ms
22,876 KB
testcase_15 AC 195 ms
46,204 KB
testcase_16 AC 197 ms
46,208 KB
testcase_17 AC 197 ms
44,116 KB
testcase_18 AC 198 ms
42,100 KB
testcase_19 AC 197 ms
46,052 KB
testcase_20 AC 197 ms
46,232 KB
testcase_21 AC 195 ms
44,036 KB
testcase_22 AC 196 ms
44,148 KB
testcase_23 AC 197 ms
42,052 KB
testcase_24 AC 195 ms
46,144 KB
testcase_25 AC 195 ms
44,056 KB
testcase_26 AC 196 ms
46,212 KB
testcase_27 AC 195 ms
44,156 KB
testcase_28 AC 198 ms
46,240 KB
testcase_29 AC 191 ms
46,116 KB
testcase_30 AC 79 ms
22,724 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let solve (k: int64) 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 >= (int64 len_loop) && (k - (int64 len_loop)) % 2L = 0L

let () =
    let _, k = stdin.ReadLine()
               |> fun s -> s.Split()
               |> Array.map int64
               |> 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