From a95bc055e590dd14c219b87631687365c65623cf Mon Sep 17 00:00:00 2001 From: sh0723 Date: Wed, 27 May 2026 16:24:37 +0900 Subject: [PATCH] =?UTF-8?q?4659=20:=20=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8?= =?UTF-8?q?=20=EB=B0=9C=EC=9D=8C=ED=95=98=EA=B8=B0=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week2/BOJ4659/BOJ4659_V1.cpp | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/week2/BOJ4659/BOJ4659_V1.cpp diff --git a/src/week2/BOJ4659/BOJ4659_V1.cpp b/src/week2/BOJ4659/BOJ4659_V1.cpp new file mode 100644 index 0000000..5b2714c --- /dev/null +++ b/src/week2/BOJ4659/BOJ4659_V1.cpp @@ -0,0 +1,57 @@ +#include +using namespace std; +unordered_set vowels = {'a', 'e', 'i', 'o', 'u'}; +bool check(string s) { + int vowels_cnt = 0; + int consonant_cnt = 0; + bool flag = true; + if (vowels.find(s[0]) != vowels.end() && s.size() == 1) { + return true; + } + + if (vowels.find(s[0]) != vowels.end()) { + vowels_cnt++; + flag = false; + } else { + consonant_cnt++; + } + char before_c = s[0]; + for (int i = 1; i < s.length(); i++) { + if (before_c == s[i] && !(s[i] == 'e' || s[i] == 'o')) return false; + + if (vowels.find(s[i]) == vowels.end()) { + consonant_cnt++; + if (consonant_cnt == 3) return false; + vowels_cnt = 0; + } else { + vowels_cnt++; + if (vowels_cnt == 3) return false; + consonant_cnt = 0; + flag = false; + } + before_c = s[i]; + } + + if (flag) return false; + + return true; +} +int main() { + ios_base::sync_with_stdio(false); + + + + while(true) { + string s; + cin >> s; + if (s == "end") break; + if (check(s)) { + cout << "<" << s << "> " << "is acceptable.\n"; + } else { + cout << "<" << s << "> " << "is not acceptable.\n"; + } + } + + + return 0; +} \ No newline at end of file