Skip to content

Instantly share code, notes, and snippets.

@ctylim
Created September 20, 2015 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctylim/2f8e4dcd7d50aba7288b to your computer and use it in GitHub Desktop.
Save ctylim/2f8e4dcd7d50aba7288b to your computer and use it in GitHub Desktop.
TTPC2015_G
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
int inputValue(){
int a;
cin >> a;
return a;
};
void inputArray(int * p, int a){
rep(i, a){
cin >> p[i];
}
};
void inputVector(vector<int> * p, int a){
rep(i, a){
int input;
cin >> input;
p -> push_back(input);
}
}
template <typename T>
void output(T a, int precision) {
if(precision > 0){
cout << setprecision(precision) << a << "\n";
}
else{
cout << a << "\n";
}
}
bool check[101] = {false};
int main(int argc, const char * argv[]) {
// source code
string s;
cin >> s;
// 文字数は6の倍数でなくてはいけない
int num = (int)s.size() / 6;
if(num * 6 != s.size()){
output("No", 0);
return 0;
}
vector<int> lastT;
reverse(s.begin(), s.end());
rep(i, num){
int state = 0;
rep(j, s.size()){
if (state == 0 && s[j] == 'h' && check[j] == false) {
check[j] = true;
state++;
}
if (state == 1 && s[j] == 'c' && check[j] == false) {
check[j] = true;
state++;
}
if (state == 2 && s[j] == 'e' && check[j] == false) {
check[j] = true;
state++;
}
if (state == 3 && s[j] == 't' && check[j] == false) {
check[j] = true;
state++;
}
if (state == 4 && s[j] == 'i' && check[j] == false) {
check[j] = true;
lastT.push_back(j);
break;
}
}
}
if (lastT.size() != num) {
output("No", 0);
return 0;
}
rep(i, num){
rep(j, s.size()){
if (s[j] == 't' && check[j] == false && j > lastT[i]) {
check[j] = true;
break;
}
}
}
bool ret = true;
rep(i, s.size()){
if (check[i] == false) {
ret = false;
}
}
output(ret ? "Yes" : "No", 0);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment