結果

問題 No.996 Phnom Penh
ユーザー plin92793134plin92793134
提出日時 2020-02-23 14:35:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,607 bytes
コンパイル時間 1,126 ms
コンパイル使用メモリ 102,928 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-18 08:42:31
合計ジャッジ時間 5,224 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
9,088 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 17 ms
5,376 KB
testcase_14 AC 17 ms
5,376 KB
testcase_15 AC 17 ms
5,376 KB
testcase_16 AC 17 ms
5,376 KB
testcase_17 AC 17 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,ns;cin>>s;
  string phonm="phnom",penh="penh";
  ll cnt=0;
  auto op1=[&]{
    ns="";
    bool f=0;
    ll l=s.length();
    rep(i,l){
      if(i+4<l&&s.substr(i,5)==phonm){
        f=1;
        ns+=penh;
        cnt++;
        i+=4;
      }
      else ns+=s[i];
    }
    swap(s,ns);
    return f;
  };
  auto op2=[&]{
    ns="";
    ll l=s.length();
    bool f=0;
    rep(i,l){
      if(s[i]=='h'){
        f=1;
        continue;
      }
      if(s[i]=='e'){
        f=1;
        ns+='h';
      }
      else ns+=s[i];
    }
    swap(s,ns);
    if(f)cnt++;
    return f;
  };
//  cout<<s<<endl;
  while(1){
    //cout<<s<<endl;
    op1();
    //cout<<s<<endl;
    if(!op2())break;
  }
  op2();
  cout<<cnt<<endl;

  return 0;

}
0