はまやんはまやんはまやん

hamayanhamayan's blog

Hitachi String [Social Infrastructure Information Systems Division, Hitachi Programming Contest 2020 A]

https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_a

解説

https://atcoder.jp/contests/hitachi2020/submissions/10690930

まず、文字列長が奇数であれば、hitachi文字列にはなりえない。
偶数であれば、2つずつ文字列を区切って、hiかどうかを確かめていけばいい。

string S;
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
    int n = S.length();

    if (n % 2 == 1) return no;
    rep(i, 0, n / 2) if (S.substr(i * 2, 2) != "hi") return no;

    return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
    cout << solve() << endl;
}