結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2020-05-16 00:02:31 |
| 言語 | F# (F# 4.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 990 bytes |
| コンパイル時間 | 10,401 ms |
| コンパイル使用メモリ | 186,836 KB |
| 実行使用メモリ | 71,068 KB |
| 最終ジャッジ日時 | 2024-09-19 14:44:15 |
| 合計ジャッジ時間 | 16,814 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 TLE * 1 -- * 13 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (348 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/
ソースコード
// Learn more about F# at http://fsharp.org
open System
let rec ok (a: seq<int>) (seen: Set<int>) =
match a |> Seq.tryHead with
| None -> true
| Some(x) ->
if seen.Contains x
then false
else ok (a |> Seq.skipWhile (fun y -> y = x)) (seen.Add x)
[<EntryPoint>]
let main argv =
let n = stdin.ReadLine() |> int
let a =
stdin.ReadLine().Split()
|> Array.map (fun x -> int (x) - 1)
|> Array.toSeq
if (ok a (new Set<int>([]))) then
printfn "0"
exit 0
let mutable freq = Array.create n 0
for x in a do
freq.[x] <- freq.[x] + 1
match freq |> Array.tryFindIndex (fun v -> v >= 2) with
| None -> printfn "0"
| Some(x) ->
let b =
[ (a |> Seq.skipWhile (fun y -> y = x))
(a |> Seq.takeWhile (fun y -> y = x)) ]
|> Seq.concat
if (ok b (new Set<int>([]))) then printfn "1" else printfn "-1"
0 // return an integer exit code
ikd