SRM486 Div2 Easy(250) TxMsg
Div2 250にしては面倒な気がする。
#include <string> #include <sstream> using namespace std; class TxMsg{public: string getMessage( string original ) { bool vowel[256] = { false }; vowel['a'] = vowel['e'] = vowel['i'] = vowel['o'] = vowel['u'] = true; string ans = ""; stringstream ss(original); string word; while ( ss >> word ) { string abbr = ""; for ( int i=0; i<(int)word.length(); i++ ) if ( ! vowel[word[i]] && ( i == 0 || vowel[word[i-1]] ) ) abbr += word[i]; ans += " " + ( abbr!="" ? abbr : word ); } return ans.substr(1); }};