제출 #954152

#제출 시각아이디문제언어결과실행 시간메모리
954152AlanGenetics (BOI18_genetics)C++17
0 / 100
10 ms8616 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, ptr = 0; 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) { assert(diff(dq.front(), dq.back()) == k); 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; }

컴파일 시 표준 에러 (stderr) 메시지

genetics.cpp: In function 'int main()':
genetics.cpp:17:15: warning: unused variable 'ptr' [-Wunused-variable]
   17 |  int n, m, k, ptr = 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...