#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
8652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
8652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |