結果
問題 | No.360 増加門松列 |
ユーザー |
![]() |
提出日時 | 2016-09-13 00:40:56 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 1,209 bytes |
コンパイル時間 | 8,834 ms |
コンパイル使用メモリ | 189,476 KB |
実行使用メモリ | 47,360 KB |
最終ジャッジ日時 | 2024-12-24 04:36:16 |
合計ジャッジ時間 | 12,446 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (230 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/
ソースコード
open Systemlet rec insertions x = function| [] -> [[x]]| (y :: ys) as l -> (x::l)::(List.map (fun x -> y::x) (insertions x ys))let rec permutations = function| [] -> seq [ [] ]| x :: xs -> Seq.concat (Seq.map (insertions x) (permutations xs))let ri () = stdin.ReadLine() |> intlet ria () = stdin.ReadLine().Split() |> Array.map intlet zip3 a b c =Seq.zip a b|> Seq.zip c|> Seq.map (fun (z,(x,y)) -> (x,y,z) )let isKadmatsu (x,y,z) = ( x <> y ) && ( y <> z) && (x <> z) && ( ((x < y) && (y > z)) || ((x > y) && (y < z)))let isAscendingKadomatsu ((x:int),(y:int),(z:int)) = ( isKadmatsu (x,y,z) ) && (x < z)let isAscendingKadomatsuSeq (a:int list) =let a3 = zip3 a (Seq.skip 1 a) (Seq.skip 2 a)a3 |> Seq.map isAscendingKadomatsu |> Seq.reduce (fun x s -> x && s)type Sol() =member this.Solve() =let D = ria() |> Array.toListlet permu = permutations Dlet ret = Seq.tryFind (fun ar -> isAscendingKadomatsuSeq ar ) permuif (Option.isSome ret) then "YES" else "NO"|> printfn "%s"let mySol = new Sol()mySol.Solve()