#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int main() {
cin.sync_with_stdio(false);
cin >> n >> m >> k;
vector<string> lines;
for (int i = 0; i < n; i++) {
string line;
cin >> line;
lines.push_back(line);
}
random_device rd;
mt19937 g(rd());
vector<int> order(n);
for (int i = 0; i < n; i++)
order[i] = i;
shuffle(order.begin(), order.end(), g);
vector<int> candidates = order;
for (int j = 0; j < n; j++) {
vector<int> new_candidates;
for (int i = 0; i < candidates.size(); i++) {
if (candidates[i] == order[j]) {
new_candidates.push_back(candidates[i]);
continue;
}
int diff = 0;
for (int s = 0; s < m; s++)
if (lines[order[j]][s] != lines[candidates[i]][s])
diff++;
if (diff == k)
new_candidates.push_back(candidates[i]);
}
candidates = new_candidates;
}
assert(candidates.size() == 1);
cout << candidates[0] + 1 << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |