근본없는 코딩
[C++] 백준1316 그룹 단어 체커 본문
#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;
}
'✔ Online Judge' 카테고리의 다른 글
[Python] 백준 2583 영역 구하기 (3) | 2024.02.05 |
---|---|
[C++] 백준25206 너의 평점은 (0) | 2023.06.29 |
[C++] 백준2941 크로아티아 알파벳 (0) | 2023.06.29 |
[C++] 백준4344 평균은 넘겠지 (0) | 2023.06.29 |
[C++] 백준1157 단어공부 (0) | 2023.06.29 |