結果

問題 No.996 Phnom Penh
ユーザー kuhakukuhaku
提出日時 2020-02-22 03:02:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,516 bytes
コンパイル時間 2,434 ms
コンパイル使用メモリ 199,228 KB
実行使用メモリ 11,176 KB
最終ジャッジ日時 2024-04-17 19:38:18
合計ジャッジ時間 5,927 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	string s;
	cin >> s;
	string ph = "phnom";
	ll cnt = 0;
	bool flg;
	while(true){
		flg = false;
		for(ll i = 0; i < (ll)s.size()-4; ++i){
			if(s.substr(i, 5) == ph){
				string u = s.substr(0, i)+"penh"+s.substr(i+5, s.size()-i-5);
				s = u;
				cnt++;
				flg = true;
				break;
			}
		}
		if(flg) continue;

		flg = false;
		for(ll i = s.size()-1; i >= 0; --i){
			if(s[i] == 'h'){
				s.erase(i, 1);
				flg = true;
			}else if(s[i] == 'e'){
				s[i] = 'h';
				flg = true;
			}
		}
		if(flg) cnt++;
		else break;
	}
	cout << cnt << endl;

	return 0;
}
0