HE April Circuits 1A - Bear and Vowels ( Simulation )
https://www.hackerearth.com/april-circuits/algorithm/circ-bear-and-vowels-2/
Simply simulate as the description provides.
#include <bits/stdc++.h> using namespace std; const int MAXS = 50 + 2; const string vowel = "aeiouy"; string s; void solve(){ int vowel_cnt = 0, non_vowel_cnt = 0; for( int i = 0; i < s.size(); ++i ){ bool is_vowel = false; for( int j = 0; j < vowel.size(); ++j ) if( s[ i ] == vowel[ j ] ) is_vowel = true; if( is_vowel ) ++vowel_cnt; else ++non_vowel_cnt; } if( non_vowel_cnt > vowel_cnt ) return ( void ) puts( "hard" ); int non_vowel_cs = 0; // consecutive sum for( int i = 0; i < s.size(); ++i ){ bool is_vowel = false; for( int j = 0; j < vowel.size(); ++j ) if( s[ i ] == vowel[ j ] ) is_vowel = true; if( !is_vowel ) ++non_vowel_cs; else non_vowel_cs = 0; if( non_vowel_cs == 3 ) return ( void ) puts( "hard" ); } puts( "easy" ); } int main(){ int T; scanf( "%d", &T ); while( T-- ){ cin >> s; solve(); } return 0; }