結果

問題 No.345 最小チワワ問題
ユーザー guriceringuricerin
提出日時 2020-01-08 10:37:08
言語 F#
(F# 4.0)
結果
TLE  
実行時間 -
コード長 1,170 bytes
コンパイル時間 3,694 ms
コンパイル使用メモリ 163,672 KB
実行使用メモリ 30,324 KB
最終ジャッジ日時 2023-08-15 00:24:18
合計ジャッジ時間 9,874 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let solve() =
    let ss = readChars()
    let len = Array.length ss
    let mutable ans = Int32.MaxValue
    for i in 0 .. len - 1 do
        if ss.[i] = 'c' then
            let mutable w = 0
            let mutable j = i + 1
            while w < 2 && j < len do
                if ss.[j] = 'w' then w <- w + 1
            if w = 2 then ans <- min ans (i - j + 1)

    let ans =
        if ans = Int32.MaxValue then -1 else ans
    ans |> puts
    ()

[<EntryPoint>]
let main _ =
    try
        solve()
    with e -> printfn "%s" (e.ToString())
    writer.Close()
    0 // return an integer exit code
0