B - choku語 / AtCoderBeginnerContest #017
#include <iostream> #include <string> using namespace std; void Solve(string x) { int pos=0; while( pos < x.length() ) { if (x[pos]=='c' && x[pos+1]=='h') pos+=2; else if (x[pos] == 'o') ++pos; else if (x[pos] == 'k') ++pos; else if (x[pos] == 'u') ++pos; else break; } cout << (pos==x.length()? "YES" : "NO") << endl; } int main(void) { string x; cin >> x; Solve(x); return 0; }
文字列が、"ch", 'o', 'k', 'u'だけで作られている場合はYES、
そうでない場合はNOを出力。
〜了〜