#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()
vector<string> s;
vector<vi> dif;
vi ok;
int n,m,k;
int diff(int i, int j) {
if (dif[i][j]!=-1) {
return dif[i][j];
}
int cnt=0;
for (int l=0; l<m; l++) {
if (s[i][l]!=s[j][l]) {
cnt++;
}
}
dif[i][j]=cnt;
dif[j][i]=cnt;
if (cnt!=k) {
ok[i]=0;
ok[j]=0;
}
return cnt;
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k;
s.resize(n);
dif.resize(n,vi(n,-1));
ok.resize(n,1);
for (int i=0; i<n; i++) {
cin >> s[i];
}
mt19937 rnd(time(0));
vi ord1(n);
iota(all(ord1),0);
shuffle(all(ord1),rnd);
for (auto i:ord1) {
if (!ok[i]) {
continue;
}
for (auto j:ord1) {
if (i==j) {
continue;
}
if (diff(i,j)!=k) {
break;
}
}
if (ok[i]) {
cout << i+1 << '\n';
return 0;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |