結果

問題 No.1534 おなかがいたい
ユーザー natoriusannatoriusan
提出日時 2023-08-01 16:18:42
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 488 bytes
コンパイル時間 9,023 ms
コンパイル使用メモリ 185,464 KB
実行使用メモリ 43,096 KB
最終ジャッジ日時 2024-04-19 15:36:56
合計ジャッジ時間 14,456 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 305 ms
34,576 KB
testcase_01 AC 311 ms
34,036 KB
testcase_02 AC 55 ms
30,208 KB
testcase_03 AC 306 ms
33,784 KB
testcase_04 AC 301 ms
34,832 KB
testcase_05 AC 306 ms
33,520 KB
testcase_06 AC 55 ms
29,952 KB
testcase_07 AC 311 ms
34,272 KB
testcase_08 AC 308 ms
34,568 KB
testcase_09 AC 315 ms
34,624 KB
testcase_10 AC 52 ms
30,208 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 67 ms
38,144 KB
testcase_14 AC 68 ms
38,144 KB
testcase_15 AC 313 ms
35,704 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 314 ms
36,032 KB
testcase_20 AC 325 ms
42,896 KB
testcase_21 AC 311 ms
34,548 KB
testcase_22 AC 313 ms
34,584 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (289 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

let s = stdin.ReadLine ()

let mutable pon_count = 0
let mutable prev = 'n'
for i in 0..s.Length-1 do
    if s.[i..i+3] = "pain" then
        printfn "%d" (if pon_count < 2 then -1 else pon_count - 1)
        exit 0
    else
        match prev, s.[i] with
        | 'n', 'p' ->
            prev <- 'p'
        | 'p', 'o' ->
            prev <- 'o'
        | 'o', 'n' ->
            prev <- 'n'
            pon_count <- pon_count + 1
        | _ ->
            ()
            
printfn "-1"
0