aboutsummaryrefslogtreecommitdiff
path: root/contests/Round#790/10-10-2022(Div4)/C
diff options
context:
space:
mode:
Diffstat (limited to 'contests/Round#790/10-10-2022(Div4)/C')
-rw-r--r--contests/Round#790/10-10-2022(Div4)/C/C.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/contests/Round#790/10-10-2022(Div4)/C/C.cpp b/contests/Round#790/10-10-2022(Div4)/C/C.cpp
new file mode 100644
index 0000000..68eda3d
--- /dev/null
+++ b/contests/Round#790/10-10-2022(Div4)/C/C.cpp
@@ -0,0 +1,28 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ int tt;
+ cin >> tt;
+ while(tt--) {
+ int n, m;
+ cin >> n >> m;
+ vector<string> v(n);
+ vector<int> ans;
+ for(auto &s : v) {
+ cin >> s;
+ }
+ for(int i = 0; i < v.size() - 1;i++) {
+ for(int j = i + 1;j < v.size();j++){
+ int sum = 0;
+ for(int k = 0; k < v[i].size(); k++) {
+ sum+=abs(v[i][k] - v[j][k]);
+ }
+ ans.push_back(sum);
+ }
+ }
+ cout << *min_element(ans.begin(), ans.end()) << endl;
+ }
+
+}