✔ Online Judge
[C++] 백준1316 그룹 단어 체커
근본없는 개발자
2023. 6. 29. 23:55
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, cnt=0;
int arr[30] = { 0 };
char str[101];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> str;
for (int j = 0; j < 26; j++) arr[j] = -1;
for (int j = 0; j < 101; j++) {
if (str[j] == '\0') {
cnt++;
break;
}
if (arr[str[j] - 'a'] == -1 || j - arr[str[j] - 'a'] <= 1)
arr[str[j] - 'a'] = j;
else
break;
}
}
cout << cnt << '\n';
return 0;
}