-
Notifications
You must be signed in to change notification settings - Fork 0
/
ACMICPC.cpp
39 lines (36 loc) · 839 Bytes
/
ACMICPC.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
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <bitset> // Very useful for this problem, converts a given string or int to an array of bits
using namespace std;
#define MAXLEN 501
int main() {
int n, m;
cin >> n >> m;
string s;
vector<bitset<MAXLEN> > v;
for (int i = 0; i < n; i++) {
cin >> s;
bitset<MAXLEN> bit(s);
v.push_back(bit);
}
int pick = 0, count = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
bitset<MAXLEN> t = v[i] | v[j]; // find suitable person with OR
if (t.count() > pick) {
pick = t.count(); // count the bits
count = 1;
}
else
if (t.count() == pick)
count++;
}
}
cout << pick << endl;
cout << count;
return 0;
}