-
Notifications
You must be signed in to change notification settings - Fork 0
/
[BOJ] 1316 그룹 단어 체커.cpp
48 lines (38 loc) · 1023 Bytes
/
[BOJ] 1316 그룹 단어 체커.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <vector>
using namespace std;
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
int N;
vector<string> v;
int answer = 0;
cin >> N;
for (int i = 0; i < N; i++) {
string s;
cin >> s;
v.push_back(s);
vector<char> visited;
bool flag = true;
char before = v[i][0];
visited.push_back(before);
for (int j = 1; j < v[i].size(); j++) {
if (before != v[i][j]) {
bool isVisited = true;
for (int k = 0; k < visited.size(); k++) {
if (visited[k] == v[i][j]) {
isVisited = false;
flag = false;
break;
}
}
if (!isVisited) break;
visited.push_back(v[i][j]);
before = v[i][j];
}
}
if (flag) answer++;
}
cout << answer;
return 0;
}