# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916601 | 406 | Genetics (BOI18_genetics) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int int64_t
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ar = array<int, 2>;
const int64_t INF = 1ll << 60;
const int N = 4200;
int n, m, k;
vector<pair<string, int>> a, tmp;
bool get(const string &s1, const string &s2) {
int x = 0;
FOR(i, 0, m) {
x += s1[i] != s2[i];
if (x > k) return false;
}
return x == k;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> k;
a.resize(n);
(i, 0, n) {
string s;
cin >> s;
a[i] = {s, i};
}
mt19937 rng((int64_t) new char);
tmp = a;
//shuffle(a.begin(), a.end(), rng);
/*
while (a.size() >= 10) {
int i = rng() % a.size(), j;
do {
j = rng() % a.size();
} while (j == i);
if (!get(a[i].first, a[j].first)) {
if (i > j) swap(i, j);
a.erase(a.begin() + j);
a.erase(a.begin() + i);
}
}
*/
FOR(i, 0, a.size()) {
bool f = true;
for (auto &[s, x]: tmp) if (x != a[i].second)
f &= get(a[i].first, s);
if (f) {
cout << a[i].second + 1;
return 0;
}
}
return 0;
}