-
[4659] 비밀번호 발음하기BOJ 2022. 5. 14. 14:34
https://www.acmicpc.net/problem/4659
4659번: 비밀번호 발음하기
좋은 패스워드를 만드는것은 어려운 일이다. 대부분의 사용자들은 buddy처럼 발음하기 좋고 기억하기 쉬운 패스워드를 원하나, 이런 패스워드들은 보안의 문제가 발생한다. 어떤 사이트들은 xvtp
www.acmicpc.net
요구사항이 많으므로 세심히 짤 필요가 있겠다.
#include <bits/stdc++.h>using namespace std;#ifdef ONLINE_JUDGEconstexpr bool local = false;#elseconstexpr bool local = true;#endifusing ll = long long;using pi = pair<ll, ll>;string s;int f(char x) {return (x == 'a' or x == 'e' or x == 'i' or x == 'o' or x == 'u') ? 1 : 0;}int main(void) {if (!local) ios_base::sync_with_stdio(0), cin.tie(0);int i;while (1) {cin >> s;if (s == "end") break;int S = s.length();bool ans = true;cout << "<" << s << ">"<< " is ";if (find(s.begin(), s.end(), 'a') == s.end() andfind(s.begin(), s.end(), 'e') == s.end() andfind(s.begin(), s.end(), 'i') == s.end() andfind(s.begin(), s.end(), 'o') == s.end() andfind(s.begin(), s.end(), 'u') == s.end()) {ans = false;goto out;}for (i = 0; i + 2 < S; i++) {string cur = string(s.begin() + i, s.begin() + i + 3);int cnt = f(cur[0]) + f(cur[1]) + f(cur[2]);if (cnt == 0 or cnt == 3) {ans = false;goto out;}}for (i = 0; i + 1 < S; i++) {string cur = string(s.begin() + i, s.begin() + i + 2);if (cur[0] == cur[1]) {if (cur[0] == 'e' or cur[0] == 'o');else {ans = false;goto out;}}}
out:if (!ans) cout << "not ";cout << "acceptable.\n";}return 0;}
'BOJ' 카테고리의 다른 글
[18005] Even or Odd? (0) 2022.05.20 비밀번호 발음하기 (0) 2022.05.16 [4307] 개미 (0) 2022.05.14 [17413] 단어 뒤집기 2 (0) 2022.05.14 [17485] 진우의 달 여행 (Large) (0) 2022.05.14