[BOJ] 1316 그룹 단어 체커

Time Lapse :5min 2sec

1316.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <string>
using namespace std;
bool group(string s) {
bool use[26] = { false, };
for (int i = 0; i < s.length(); ++i) {
if (use[s[i] - 'a']) return false;
if (i+1<s.length()&&s[i] == s[i + 1]) continue;
use[s[i] - 'a'] = true;
}
return true;
}
int main() {
int N, ans = 0;
string s;
cin >> N;
while (N--) {
cin >> s;
if (group(s)) ++ans;
}
cout << ans;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/23/PS/BOJ/1316/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.