-
Notifications
You must be signed in to change notification settings - Fork 0
/
ACM_ICPC_Team.cpp
73 lines (49 loc) · 1.59 KB
/
ACM_ICPC_Team.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
/**
* Title : ACM ICPC Team
* Author : Tridib Samanta
* Link : https://www.hackerrank.com/challenges/acm-icpc-team/problem
**/
#include <bits/stdc++.h>
using namespace std;
void solve(int n, int m, vector<vector<string> >& topics) {
int countPairs = 0, maxTopicCount = INT_MIN;
for (int i = 0; i < n; ++i) {
string attendee1 = topics[i][0];
for (int j = i + 1; j < n; ++j) {
string attendee2 = topics[j][0];
int currTopicCount = 0;
for (int k = m - 1; k >= 0; --k) {
if (attendee1[k] - '0' || attendee2[k] - '0' == 1)
++currTopicCount;
}
if (currTopicCount > maxTopicCount)
maxTopicCount = currTopicCount;
}
}
for (int i = 0; i < n; ++i) {
string attendee1 = topics[i][0];
for (int j = i + 1; j < n; ++j) {
string attendee2 = topics[j][0];
int currTopicCount = 0;
for (int k = m - 1; k >= 0; --k) {
if (attendee1[k] - '0' || attendee2[k] - '0' == 1)
++currTopicCount;
}
if (currTopicCount == maxTopicCount)
++countPairs;
}
}
cout << maxTopicCount << '\n' << countPairs << '\n';
}
int main() {
int n, m;
cin >> n >> m;
vector<vector<string> > topics(n);
for (int i = 0; i < n; ++i) {
string str;
cin >> str;
topics[i].emplace_back(str);
}
solve(n, m, topics);
return 0;
}