代码如下
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <queue>
#include <vector>
#include <stack>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main() {
string s;
cin >> s;
queue<char>q;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'h')q.push(s[i]);
if (s[i] == 'e' && !q.empty()) { if (q.back() == 'h')q.push(s[i]); }
if (s[i] == 'i' && !q.empty()) { if (q.back() == 'e')q.push(s[i]); }
if (s[i] == 'd' && !q.empty()) { if (q.back() == 'i')q.push(s[i]); }
if (s[i] == 'i' && !q.empty()) { if (q.back() == 'd')q.push(s[i]); }
}
string a = "";
for (int i = 0; i < 200; i++) {
if (q.empty())break;
a += q.front();
if (a == "heidi") { cout << "YES"; return 0; }
q.pop();
}
cout << "NO";
return 0;
}