-
[1일 1백준: 1316번] 그룹 단어 체커Programming/백준 2021. 1. 28. 00:06
#include <iostream> #include <vector> bool IsGroupWord(std::string str) { int combo = 0; int prevANCII = str[0], ANCII = 0; bool IsAnotherNum = false; for (size_t i = 0; i < str.size(); i++) { IsAnotherNum = false; for (size_t j = i; j < str.size(); j++) { if (str[i] == str[j] && IsAnotherNum) return false; if (str[i] != str[j]) { IsAnotherNum = true; } } } return true; } int main(void) { std::cin.tie(NULL); std::cout.tie(NULL); std::ios::sync_with_stdio(false); int N = 0; std::cin >> N; std::vector<std::string> index(N); for (size_t i = 0; i < index.size(); i++) { std::cin >> index[i]; } int cnt = 0; for (size_t i = 0; i < index.size(); i++) { if (IsGroupWord(index[i])) cnt++; } std::cout << cnt << "\n"; return 0; }
1316번: 그룹 단어 체커
그룹 단어란 단어에 존재하는 모든 문자에 대해서, 각 문자가 연속해서 나타나는 경우만을 말한다. 예를 들면, ccazzzzbb는 c, a, z, b가 모두 연속해서 나타나고, kin도 k, i, n이 연속해서 나타나기 때
www.acmicpc.net
'Programming > 백준' 카테고리의 다른 글
[1일 1백준 : 2292번] 벌집 (0) 2021.01.29 [1일 1백준 : 1712번] 손익분기점 (0) 2021.01.28 [1일 1백준 : 2941번] 크로아티아 알파벳 (0) 2021.01.26 [1일 1백준 : 5622번] 다이얼 (0) 2021.01.25 [1일 1백준 : 2908번] 상수 (0) 2021.01.24