-
Notifications
You must be signed in to change notification settings - Fork 0
/
cownomics2.cpp
53 lines (51 loc) · 1.35 KB
/
cownomics2.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
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
int main() {
freopen("cownomics.in", "r", stdin);
freopen("cownomics.out", "w", stdout);
int N, M; cin >> N >> M;
string spotty[N];
string plain[N];
for (int i=0; i<N; i++) {
cin >> spotty[i];
}
for (int i=0; i<N; i++) {
cin >> plain[i];
}
int counter = 0;
for (int i=0; i<M-2; i++) {
for (int j=i+1; j<M-1; j++) {
for (int k=j+1; k<M; k++) {
set<string> already;
for (auto cow: spotty) {
string dna = "";
dna += cow[i];
dna += cow[j];
dna += cow[k];
already.insert(dna);
}
bool okay = true;
for (auto cow: plain) {
if (okay){
string dna = "";
dna += cow[i];
dna += cow[j];
dna += cow[k];
if (already.count(dna) > 0) {
okay = false;
}
}
}
if (okay) counter++;
}
}
}
cout << counter;
}