Submission #566235

#TimeUsernameProblemLanguageResultExecution timeMemory
566235two_sidesGenetics (BOI18_genetics)C++17
27 / 100
2064 ms4900 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const int N = 4005; string s[N]; int n, m, k; bool used[N]; int calc(int i, int j) { int res = 0; for (int x = 0; x < m; x++) res += s[i][x] != s[j][x]; return res; } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m >> k; vector<int> x, y; for (int i = 0; i < n; i++) { cin >> s[i]; if (x.empty()) x.push_back(i); else y.push_back(i); while (x.size() && y.size()) { if (calc(x.back(), y.back()) == k) { if (!used[y.back()]) x.push_back(y.back()); y.pop_back(); } else { used[x.back()] = true; x.pop_back(); } } } for (int i : x) { vector<int> ord(n); iota(ord.begin(), ord.end(), 0); shuffle(ord.begin(), ord.end(), rng); bool flag = true; for (int j : ord) if (i != j && calc(i, j) != k) { flag = false; break; } if (flag) return cout << i + 1, 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...