-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf-58A.cpp
44 lines (33 loc) · 1.45 KB
/
cf-58A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// A. Chat room
// time limit per test1 second
// memory limit per test256 megabytes
// inputstandard input
// outputstandard output
// Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, if Vasya types the word "ahhellllloou", it will be considered that he said hello, and if he types "hlelo", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.
// Input
// The first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.
// Output
// If Vasya managed to say hello, print "YES", otherwise print "NO".
#include<bits/stdc++.h>
using namespace std;
string solve(string s)
{
regex reg("h[a-z]*e[a-z]*l[a-z]*l[a-z]*o[a-z]*");
if (regex_search(s, reg)) return "YES";
return "NO";
}
// Driver Code
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif
string s;
cin>>s;
cout << solve(s);
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
return 0;
}