結果

問題 No.397 NO MORE KADOMATSU
ユーザー kuuso1kuuso1
提出日時 2016-08-26 00:35:46
言語 F#
(F# 4.0)
結果
RE  
実行時間 -
コード長 971 bytes
コンパイル時間 5,197 ms
コンパイル使用メモリ 171,888 KB
実行使用メモリ 43,312 KB
平均クエリ数 34.78
最終ジャッジ日時 2023-09-23 11:21:31
合計ジャッジ時間 10,421 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
41,244 KB
testcase_01 AC 114 ms
39,108 KB
testcase_02 AC 111 ms
41,244 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 114 ms
38,868 KB
testcase_10 RE -
testcase_11 AC 112 ms
39,172 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 111 ms
36,712 KB
testcase_17 AC 110 ms
38,964 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System
open System.Collections.Generic

let ri () = stdin.ReadLine() |> int
let ria () = stdin.ReadLine().Split() |> Array.map int
let swap a b (xs:'t []) = 
    let tmp = xs.[a]
    xs.[a] <- xs.[b]
    xs.[b] <- tmp

type Sol() =
    member this.Solve() = 
        let N = ri ()
        let A = ria ()
        
        let L = new List<int*int> ()
        for i in 0..(N-2) do
            let m = A |> Array.skip i |> Array.min
            let trgt = A |> Array.skip i |> Array.findIndex ( (=) m ) |> (+) i
            
            // printfn "%s" (String.Join(" ",A))
            // printfn "min: %d" m
            // printfn "midx:%d" trgt
            
            
            if trgt <> i then (
                swap m trgt A ;
                L.Add(i,trgt)
            )
        
        L.Count |> printfn "%d"
        L |> Seq.iter (fun (a,b) -> printfn "%d %d" a b)
        
        let dummy = ri()
        ()
        
let mySol = new Sol()
mySol.Solve()
0