forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path127.cpp
More file actions
52 lines (47 loc) · 816 Bytes
/
127.cpp
File metadata and controls
52 lines (47 loc) · 816 Bytes
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
//ac
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class phone {
public:
string num;
bool operator < (const phone &t) const {
if (num[0] != t.num[0]) {
return num[0] < t.num[0];
} else if (num[1] != t.num[1]) {
return num[1] < t.num[1];
} else if (num[2] != t.num[2]) {
return num[2] < t.num[2];
} else {
return num[3] < t.num[3];
}
}
};
void run() {
int k, n;
cin >> k >> n;
vector<phone> mm(n);
for (int i = 0; i < n; ++i) cin >> mm[i].num;
sort(mm.begin(), mm.end());
int ret = 2, c = 0;
char last = '*';
for (int i = 0; i < n; ++i) {
if (mm[i].num[0] != last) {
++ret;
last = mm[i].num[0];
c = 1;
} else {
++c;
if (c == k + 1) {
c = 1;
++ret;
}
}
}
cout << ret << endl;
}
int main() {
run();
return 0;
}