forked from encrypted-def/BOJ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1034.cpp
42 lines (41 loc) · 767 Bytes
/
1034.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
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
int N, M, K;
char lamp[51][51];
int D[51];
int main(void) {
scanf("%d %d", &N, &M);
for (int i = 0; i < N; i++)
scanf("%s", lamp[i]);
scanf("%d", &K);
vector<long long> V;
for (int i = 0; i < N; i++) {
long long val = 0;
int num0 = 0;
for (int j = 0; j < M; j++) {
val = 2 * val + (lamp[i][j] - '0');
num0 += (lamp[i][j] == '0');
}
if (num0 > K || (K - num0) % 2 != 0)
continue;
V.push_back(val);
}
sort(V.begin(), V.end());
if (V.empty()) {
printf("0");
return 0;
}
D[0] = 1;
int mx = 1;
for (int i = 1; i < V.size(); i++) {
if (V[i] == V[i - 1]) {
D[i] = D[i - 1] + 1;
mx = max(mx, D[i]);
}
else
D[i] = 1;
}
printf("%d", mx);
}