알고리즘/백준

그룹 단어 체커

슈도코드 2019. 10. 24. 22:45

#include <iostream>
#include <string>
using namespace std;

int cnt;

void Checker(string word)
{
	int len = word.size();

	for (int i = 0; i < len - 2; i++)
	{
		if (word[i] != word[i + 1])
		{
			for (int j = i + 2; j < len; j++)
				if (word[j] == word[i])
					return;
		}
	}
	cnt++;
}

int main()
{
	int num;
	string word;

	cin >> num;

	for (int i = 0; i < num; i++)
	{
		cin >> word;
		Checker(word);
	}
	cout << cnt << '\n';
	return 0;
}