結果

問題 No.996 Phnom Penh
ユーザー mamekinmamekin
提出日時 2020-02-24 14:00:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,666 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 116,588 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-02 08:57:20
合計ジャッジ時間 3,138 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int ans = 0;
    int i = 0;
    string t;
    while(i < n){
        if(s.substr(i, 5) == "phnom"){
            t += "penh";
            i += 5;
            ++ ans;
        }
        else{
            t += s[i];
            ++ i;
        }
    }
    s = move(t);
    n = s.size();

    t = string();
    if(s.find('h') != string::npos || s.find('e') != string::npos){
        for(int i=0; i<n; ++i){
            if(s[i] != 'h'){
                if(s[i] == 'e')
                    t += 'h';
                else
                    t += s[i];
            }
        }
        ++ ans;
    }
    s = move(t);
    n = s.size();
    
    int maxLen = (s.find('h') == string::npos)? 0 : 1;
    i = 0;
    while(i < n){
        if(s.substr(i, 5) == "phnom"){
            i += 5;
            int len = 1;
            while(i < n && s.substr(i, 2) == "om"){
                i += 2;
                ++ len;
            }
            ans += len;
            maxLen = max(maxLen, len + 1);
        }
        else{
            ++ i;
        }
    }
    ans += maxLen;
    cout << ans << endl;

    return 0;
}
0