Submission #954191

#TimeUsernameProblemLanguageResultExecution timeMemory
954191AlanGenetics (BOI18_genetics)C++17
0 / 100
9 ms8652 KiB
#include <bits/stdc++.h> using namespace std; string s[4105], t[4105]; map<string, int> mp; bool bad[4105]; int diff (int x, int y) { int cnt = 0; for (int i = 0; i < (int) s[x].size(); i++) cnt += s[x][i] != s[y][i]; return cnt; } int main () { ios::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= n; i++) { cin >> s[i]; mp[s[i]]++; } for (int i = 1; i <= n; i++) if (mp[s[i]] > 1) bad[i] = true; deque<int> dq; for (int i = 1; i <= n; i++) if (!bad[i]) { while (i <= n && !dq.empty() && diff(dq.back(), i) != k) { i++; dq.pop_back(); } if (i > n) break; dq.push_back(i); } while ((int) dq.size() > 2) { dq.pop_front(); dq.pop_back(); } if ((int) dq.size() > 1) { for (int i = 1; i <= n; i++) if (i != dq[0] && diff(i, dq[0]) != k) { dq.pop_front(); break; } if ((int) dq.size() > 1) dq.pop_back(); } cout << dq[0] << '\n'; return 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...