結果

問題 No.1005 BOT対策
ユーザー natoriusan
提出日時 2023-07-30 11:47:03
言語 F#
(F# 4.0)
結果
AC  
実行時間 455 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 13,121 ms
コンパイル使用メモリ 199,280 KB
実行使用メモリ 57,948 KB
最終ジャッジ日時 2025-06-20 01:43:07
合計ジャッジ時間 22,274 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (348 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

let mutable s = stdin.ReadLine ()
let t = stdin.ReadLine ()
let firstLength = s.Length
let length = t.Length

let findIndex (str: string) (search: string) =
    let mutable index = -1
    for i in 0..str.Length-search.Length do
        if index = -1 && str.[i..i+search.Length-1] = search then
            index <- i
    index
    
if length = 1 then
    if s |> Seq.contains t.[0] then
        printfn "-1"
    else
        printfn "0"
else
    while findIndex s t <> -1 do
        let index = findIndex s t
        s <- s.[..index+t.Length-2] + "." + s.[index+t.Length-1..]
    s.Length - firstLength |> printfn "%d"
0