-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy path1287B.cpp
More file actions
executable file
·41 lines (34 loc) · 750 Bytes
/
1287B.cpp
File metadata and controls
executable file
·41 lines (34 loc) · 750 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
// Problem Code: 1287B
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>
using namespace std;
string find_card(string& a, string& b) {
string c;
for (int i = 0; i < a.length(); i++) {
if (a[i] == b[i])
c += a[i];
else
c += a[i] ^ b[i] ^ 'S' ^ 'E' ^ 'T';
}
return c;
}
long long hyperset(int n, vector<string>& cards) {
long long ways = 0;
unordered_set<string> seen(cards.begin(), cards.end());
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (seen.count(find_card(cards[i], cards[j])))
ways++;
return ways / 3;
}
int main() {
int n, k;
cin >> n >> k;
vector<string> cards(n);
for (int i = 0; i < n; i++)
cin >> cards[i];
cout << hyperset(n, cards);
return 0;
}