結果

問題 No.996 Phnom Penh
ユーザー Haar
提出日時 2020-02-21 23:14:27
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 378 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2024-10-09 02:16:31
合計ジャッジ時間 5,089 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 4 WA * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s = STDIN.gets

ans = 0

s.scan(/phn(?:om)+/).each do |t|
  ans += t.length - 3
end

s.gsub!(/phn(?:om)+/, "phn")

if s.include?("h") then
  ans += 1;

  s.gsub!("h", "")
  s.gsub!("e", "h")
end


s.scan(/phn(?:om)+/).each do |t|
  ans += t.length - 3
end

s.gsub!(/phn(?:om)+/, "phn")

if s.include?("h") then
  ans += 1;

  s.gsub!("h", "")
  s.gsub!("e", "h")
end


puts ans
0