728x90
반응형
https://www.acmicpc.net/problem/1316
1316번: 그룹 단어 체커
그룹 단어란 단어에 존재하는 모든 문자에 대해서, 각 문자가 연속해서 나타나는 경우만을 말한다. 예를 들면, ccazzzzbb는 c, a, z, b가 모두 연속해서 나타나고, kin도 k, i, n이 연속해서 나타나기 때
www.acmicpc.net
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, cnt = 0;
cin >> n;
string str;
for(int i = 0; i < n; i++){
cin >> str;
set<char> s;
char last = ' ';
bool isTrue = true;
for(int j = 0; j < str.length(); j++){
if(last == str[j]){
continue;
} else{
if(s.find(str[j]) != s.end()){
isTrue = false;
break;
}
s.insert(str[j]);
last = str[j];
}
}
if(isTrue) cnt++;
}
cout << cnt << endl;
return 0;
}
728x90
반응형
'Algorithm > BAEKJOON' 카테고리의 다른 글
[BOJ] 1010번 다리 놓기 (C++) (0) | 2022.01.10 |
---|---|
[BOJ] 9461번 파도반 수열 (C++) (0) | 2022.01.09 |
[BOJ] 11723번 집합 (C++) (0) | 2022.01.06 |
[BOJ] 1620번 나는야 포켓몬 마스터 이다솜 (C++) (0) | 2022.01.05 |
[BOJ] 1753번 최단경로 (C++) (0) | 2022.01.04 |