Submission #106214

#TimeUsernameProblemLanguageResultExecution timeMemory
106214Noam527Genetics (BOI18_genetics)C++17
0 / 100
2064 ms9720 KiB
#include <bits/stdc++.h> #define CHECK cout << "ok" << endl #define finish(x) return cout << x << endl, 0 typedef long long ll; typedef long double ldb; const int md = 1e9 + 7; const ll inf = 1e18; const int OO = 1; const int OOO = 1; using namespace std; int n, m, k; bool check[4101][4101] = {}; struct seq { string s; int i; seq() {} seq(const string &t, int ii) { s = t; i = ii; } }; bool good(const seq &a, const seq &b) { if (check[a.i][b.i] || check[b.i][a.i]) return true; check[a.i][b.i] = check[b.i][a.i] = 1; int cnt = 0; for (int i = 0; i < m; i++) { if (a.s[i] != b.s[i]) cnt++; if (cnt > k || cnt + m - i - 1 < k) return false; } return true; } vector<seq> s; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> m >> k; s.resize(n); for (int i = 0; i < n; i++) cin >> s[i].s, s[i].i = i + 1; srand(12342345); random_shuffle(s.begin(), s.end()); int nxt = n - 1; while (1) { int i = 1; while (i < n && good(s[0], s[i])) i++; if (i == n) finish(s[0].i); if (nxt < i) swap(s[0], s[nxt--]); else { swap(s[0], s[nxt--]); swap(s[i], s[nxt--]); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...