結果

問題 No.52 よくある文字列の問題
ユーザー guriceringuricerin
提出日時 2020-02-10 12:34:14
言語 F#
(F# 4.0)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 1,346 bytes
コンパイル時間 11,402 ms
コンパイル使用メモリ 193,040 KB
実行使用メモリ 31,156 KB
最終ジャッジ日時 2024-04-08 12:56:41
合計ジャッジ時間 13,079 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
31,028 KB
testcase_01 AC 67 ms
31,028 KB
testcase_02 AC 70 ms
31,156 KB
testcase_03 AC 68 ms
31,028 KB
testcase_04 AC 72 ms
31,156 KB
testcase_05 AC 66 ms
31,156 KB
testcase_06 AC 66 ms
31,156 KB
testcase_07 AC 66 ms
31,156 KB
testcase_08 AC 64 ms
31,028 KB
testcase_09 AC 63 ms
31,028 KB
testcase_10 AC 64 ms
31,028 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (669 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

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 main() =
    let s = read string
    let len = s.Length
    let st = SortedSet<string>()

    let rec dfs l r (t: string) =
        if l >= len || r < 0 || t.Length >= len then
            // printfn "%s" t
            st.Add(t) |> ignore
        else
            let a = t + string s.[l]
            dfs (l + 1) r a
            let b = t + string s.[r]
            dfs l (r - 1) b

    dfs 0 (len - 1) ""
    st.Count |> puts

    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()
0