結果

問題 No.26 シャッフルゲーム
ユーザー kuuso1kuuso1
提出日時 2016-08-19 01:42:33
言語 F#
(F# 4.0)
結果
AC  
実行時間 308 ms / 5,000 ms
コード長 546 bytes
コンパイル時間 7,381 ms
コンパイル使用メモリ 200,576 KB
実行使用メモリ 34,748 KB
最終ジャッジ日時 2024-04-25 09:06:35
合計ジャッジ時間 10,066 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 308 ms
34,748 KB
testcase_01 AC 301 ms
34,492 KB
testcase_02 AC 298 ms
34,640 KB
testcase_03 AC 300 ms
34,624 KB
testcase_04 AC 308 ms
34,624 KB
testcase_05 AC 299 ms
34,384 KB
testcase_06 AC 302 ms
34,628 KB
testcase_07 AC 300 ms
34,464 KB
testcase_08 AC 302 ms
34,376 KB
testcase_09 AC 300 ms
34,512 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (234 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
/home/judge/data/code/Main.fs(16,17): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj]
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

open System
let swap (cs:'t array) i j =
    let tmp = cs.[i]
    cs.[i] <- cs.[j]
    cs.[j] <- tmp


type Sol() =
    member this.Solve() = 
        let cups = [|'x';'x';'x'|]
        let N = stdin.ReadLine() |> int
        cups.[N-1] <- 'o'
        
        let M = stdin.ReadLine() |> int
        for i = 0 to (M-1) do
            let [|P;Q|] = stdin.ReadLine().Split() |> Array.map int
            swap cups (P-1) (Q-1)
        
        1 + (Array.findIndex (fun e -> e = 'o') cups ) |> printfn "%d"
    
let mySol = new Sol()
mySol.Solve()
0