結果

問題 No.996 Phnom Penh
ユーザー chocoruskchocorusk
提出日時 2020-02-21 21:57:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,348 bytes
コンパイル時間 1,029 ms
コンパイル使用メモリ 113,984 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-17 07:36:36
合計ジャッジ時間 1,970 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int solve(string s){
    int n=s.size();
    bool myon=0;
    vector<int> v;
    for(int i=0; i<n; i++){
        if(s[i]=='h') myon=1;
        if(!(i+4<=n-1 && s.substr(i, 5)=="phnom")) continue;
        int cnt=1;
        for(int j=i+5; j<n; j+=2){
            if(!(j<n-1 && s[j]=='o' && s[j+1]=='m')) break;
            cnt++;
        }
        v.push_back(cnt);
    }
    if(v.empty()){
        if(myon) return 1;
        else return 0;
    }
    int ans=*max_element(v.begin(), v.end());
    ans=ans*2+1;
    return ans;
}
int main()
{
    string s; cin>>s;
    int n=s.size();
    int ans=solve(s);
    string t;
    for(int i=0; i<n; i++){
        if(s[i]=='h') continue;
        t+=s[i];
        if(t.back()=='e') t.back()='h';
    }
    ans=max(ans, solve(t)+1);
    cout<<ans<<endl;
    return 0;
}
0