結果

問題 No.1053 ゲーミング棒
ユーザー ikdikd
提出日時 2020-05-15 23:10:50
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 6,697 ms
コンパイル使用メモリ 191,268 KB
実行使用メモリ 74,416 KB
最終ジャッジ日時 2023-10-19 16:54:05
合計ジャッジ時間 19,558 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 357 ms
36,508 KB
testcase_01 AC 76 ms
32,492 KB
testcase_02 AC 355 ms
36,508 KB
testcase_03 AC 355 ms
36,496 KB
testcase_04 AC 355 ms
36,496 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 354 ms
36,508 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 357 ms
36,516 KB
testcase_12 AC 356 ms
36,516 KB
testcase_13 WA -
testcase_14 AC 75 ms
32,492 KB
testcase_15 AC 355 ms
36,508 KB
testcase_16 AC 74 ms
32,492 KB
testcase_17 AC 354 ms
36,508 KB
testcase_18 AC 352 ms
36,496 KB
testcase_19 WA -
testcase_20 AC 75 ms
32,492 KB
testcase_21 AC 75 ms
32,492 KB
testcase_22 AC 355 ms
36,516 KB
testcase_23 AC 111 ms
46,180 KB
testcase_24 AC 112 ms
46,244 KB
testcase_25 AC 649 ms
74,416 KB
testcase_26 AC 622 ms
70,176 KB
testcase_27 WA -
testcase_28 AC 75 ms
32,496 KB
testcase_29 AC 76 ms
32,496 KB
testcase_30 WA -
testcase_31 AC 385 ms
48,872 KB
testcase_32 AC 385 ms
48,872 KB
testcase_33 AC 383 ms
48,888 KB
testcase_34 AC 384 ms
48,888 KB
testcase_35 AC 388 ms
49,944 KB
testcase_36 AC 386 ms
50,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (232 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
    let n = stdin.ReadLine() |> int

    let a =
        stdin.ReadLine().Split()
        |> Array.map (fun x -> int (x) - 1)
        |> Array.toList

    let mutable freq = Array.create n 0
    for x in a do
        freq.[x] <- freq.[x] + 1
    if freq |> Array.forall (fun v -> v <= 1) then
        printfn "0"
        exit 0
    let x = freq |> Array.findIndex (fun v -> v >= 2)
    let b =
        List.append (a |> List.skipWhile (fun y -> y = x))
            (a |> List.takeWhile (fun y -> y = x))

    let rec ok (c: List<int>) (seen: Set<int>) =
        if c.IsEmpty then
            true
        else
            let x = c.Head
            if seen.Contains x
            then false
            else ok (c |> List.skipWhile (fun y -> y = x)) (seen.Add x)
    printfn "%d" (if (ok b (new Set<int>([]))) then 1 else -1)
    0 // return an integer exit code
0