백준 #1316 문제

Hansol Lee·2021년 7월 25일
0

백준

목록 보기
3/10

백준 1316번 문제 풀이

문제:https://www.acmicpc.net/problem/1316

풀이:
#include
using namespace std;

int main() {
int N, j, cnt = 0;
string str;
int arr[26];
cin >> N;
for (int i = 0; i < N; i++) {
	cin >> str;
	fill_n(arr, 26, 0);

	arr[str[0] - 97] = 1;
	for (j = 1; j < str.length(); j++) {
		if (str[j - 1] != str[j]) {
			int idx = str[j] - 97;
			if (arr[idx] == 0)
				arr[idx]++;
			else
				break;
		}
	}
	if (j == str.length())
		cnt++;
}
cout << cnt;

}

profile
얼레벌레 항상 성장하고 싶은 컴공생입니다

0개의 댓글