-
Notifications
You must be signed in to change notification settings - Fork 0
/
2607.cpp
73 lines (64 loc) · 1014 Bytes
/
2607.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;
int main(int argc, char * argv[])
{
int n;
int index = 0;
int count = 0;
int dif = 0;
int flag = 0;
int xc;
int yc;
int alp[30];
int comp[30];
string s;
memset(alp, 0, sizeof(alp));
cin >> n;
cin >> s;
for (int i = 0; i < s.length(); ++i) {
index = s[i] - 65;
++alp[index];
}
--n;
while (n--) {
memset(comp, 0, sizeof(comp));
dif = 0;
flag = 0;
xc = 0;
yc = 0;
cin >> s;
for (int i = 0; i < s.length(); ++i) {
index = s[i] - 65;
++comp[index];
}
for (int i = 0; i < 26; ++i) {
if (alp[i] == comp[i]) {
continue;
}
if (abs(alp[i] - comp[i]) > 1) { // 2ÀÌ»óÂ÷ÀÌ
flag = 1;
break;
}
else if (alp[i] < comp[i]) {
++xc;
}
else if (alp[i] > comp[i]) {
++yc;
}
if (xc > 1 || yc > 1) {
flag = 1;
break;
}
}
if (flag == 1) {
continue;
}
++count;
}
cout << count << endl;
return 0;
}