This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 4101;
int n ,m ,k ;
int vis[N];
string s[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k;
vector<int>v;
for(int i = 0 ; i < n ; i++)
{
cin >> s[i];
v.push_back(i);
}
random_shuffle(v.begin() , v.end());
while(true)
{
if(vis[v[0]])
continue;
int c;
bool flag=true;
vis[v[0]]++;
for(int i = 1 ; i < n ; i++)
{
c=0;
for(int j = 0 ; j < m ; j++)
{
if(s[v[0]][j]!=s[v[i]][j])
c++;
if(c>k)break;
}
if(c!=k)
{
vis[v[i]]++;
flag=false;
break;
}
}
if(flag)
{
cout << v[0]+1 ;
return 0;
}
random_shuffle(v.begin() , v.end());
}
}
# | 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... |