Baekjoon(C++)
[C++]백준 알고리즘 1316번
DanielSoliph
2021. 7. 14. 23:56
풀이는 아래와 같다.
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
49
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n;
cin >> n;
string word[100];
int check[26];
for(int k=0; k<26; k++){
check[k] = 0;
}
for(int i=0; i<n; i++){
cin >> word[i];
}
int count = 0;
for(int i=0; i<n; i++){
for(int k=0; k<26; k++){
check[k] = 0;
}
bool break_out = false;
for(int j=0; j<word[i].length(); j++){
if(check[word[i][j]-'a'] == 0){
if(j<word[i].length()-1 && word[i][j+1] == word[i][j]){
check[word[i][j]-'a'] = 0;
}else{
check[word[i][j]-'a'] = 1;
}
}else{
break_out = true;
break;
}
}
if(break_out == true){
continue;
}
count++;
}
cout << count << '\n';
return 0;
}
|
cs |
반응형