Sunday, May 1, 2016

Codeforces 58A - Chat room

#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
using namespace std;
int main()
{
    int cse=0,cnt=0,flg=0;
   string s,temp="";
   while(getline(cin,s)){
    int h=0,e=0,l=0,o=0;
    if(s.size()<5)
        cout<<"NO\n";
    else{
    ff(i,0,s.size()){
       if(s[i]!='h'&&s[i]!='e'&&s[i]!='l'&&s[i]!='o'){
        s[i]='\0';
       }
    }
    ff(i,0,s.size()){
        if(s[i]=='h'&&(temp=="")){
            string str="h";
            temp+=str;
        }
        else if(s[i]=='e'&&(temp=="h")){
            string str="e";
        temp+=str;
        }
        else if(s[i]=='l'&&(temp=="hel"||temp=="he")){
            string str="l";
            temp+=str;
        }
        else if(s[i]=='o'&&(temp=="hell")){
            string str="o";
            temp+=str;
        }
    }
    if(temp=="hello")
        cout<<"YES\n";
    else
        cout<<"NO\n";
    }
    temp="";
   }

    return 0;
}

No comments:

Post a Comment