-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20529.h
50 lines (44 loc) · 872 Bytes
/
20529.h
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
#pragma once
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
int T, N;
string G[32];
int calcDist(string s1, string s2, string s3) {
int dist = 0;
for (int i = 0; i < 4; i++)
if (s1[i] != s2[i])
dist++;
for (int i = 0; i < 4; i++)
if (s2[i] != s3[i])
dist++;
for (int i = 0; i < 4; i++)
if (s3[i] != s1[i])
dist++;
return dist;
}
int main_20529() {
cin >> T;
string temp;
for (int a = 0; a < T; a++) {
cin >> N;
if (N > 32) {
for (int i = 0; i < N; i++)
cin >> temp;
cout << 0 << endl;
continue;
}
for (int i = 0; i < N; i++) {
cin >> temp;
G[i] = temp;
}
int minimum = INT_MAX;
for (int i = 0; i < N; i++)
for (int j = i + 1; j < N; j++)
for (int k = j + 1; k < N; k++)
minimum = min(minimum, calcDist(G[i], G[j], G[k]));
cout << minimum << endl;
}
return 0;
}