結果

問題 No.996 Phnom Penh
ユーザー LCA_TrimLCA_Trim
提出日時 2020-02-21 23:18:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 951 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 94,260 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-17 09:20:04
合計ジャッジ時間 4,347 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 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 <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
	string str;
	cin >> str;

	long long count = 0;

	while (true)
	{
		auto pos = str.find("phnom");
		if (pos != string::npos)
		{
			str = str.substr(0, pos) + "penh" + str.substr(pos + 5);
			++count;
		}
		else
		{
			bool isChanged = false;
			while (true)
			{
				auto pos = str.find_first_of("h");

				if (pos == string::npos)
				{
					break;
				}

				isChanged = true;
				if (pos == str.size() + 1)
				{
					str = str.substr(0, pos);
				}
				else
				{
					str = str.substr(0, pos) + str.substr(pos + 1);
				}
			}

			for(char& c: str)
			{
				if (c == 'e')
				{
					c = 'h';
					isChanged = true;
				}
			}

			if (!isChanged)
			{
				break;
			}
			++count;
		}
	}
	cout << count << endl;
}
0