forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset.cpp
50 lines (41 loc) · 1012 Bytes
/
set.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
#include <iostream>
#include <vector>
#include <string>
using namespace std;
bool pairwise(string s1, string s2, string s3) {
int same = 0;
int diff = 0;
for(int i = 0; i < 4; i++) {
if(s1[i] == s2[i] && s2[i] == s3[i]) {
same++;
}
if(s1[i] != s2[i] && s2[i] != s3[i] && s3[i] != s1[i]) {
diff++;
}
}
return (diff + same == 4);
}
int main() {
vector<string> v;
vector<string> ans;
for(int i = 0; i < 12; i++) {
string s;
cin >> s;
v.push_back(s);
}
for(int i = 0; i < 10; i++) {
for(int j = i+1; j < 11; j++) {
for(int k = j+1; k < 12; k++) {
if(pairwise(v[i], v[j], v[k])) {
ans.push_back(to_string(i+1) + ' ' + to_string(j+1) + ' ' + to_string(k+1));
}
}
}
}
for(auto s : ans) {
cout << s << endl;
}
if(ans.size() == 0) {
cout << "no sets" << endl;
}
}