結果

問題 No.104 国道
コンテスト
ユーザー guricerin
提出日時 2020-01-08 17:10:07
言語 F#
(F# 10.0)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 1,198 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,332 ms
コンパイル使用メモリ 211,428 KB
実行使用メモリ 32,584 KB
最終ジャッジ日時 2026-05-17 00:16:52
合計ジャッジ時間 8,423 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (167 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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 ok i j k = i <> j && j <> k && i <> k

let ok2 i j k =
    let l = [ i; j; k ] |> List.sort
    List.min l = j || List.max l = j

let left i = i * 2
let right i = i * 2 + 1

let loop s =
    let lim = Array.length s

    let rec go j acc =
        if j >= lim then
            acc
        else
            match s.[j] with
            | 'L' -> go (j + 1) (left acc)
            | _ -> go (j + 1) (right acc)

    go 0 1

let solve() =
    let s = readChars()
    loop s |> puts

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