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;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
int n,m,k;
cin>>n>>m>>k;
string tab[n];
vector<int> per(n);
vector<int> cte(n);
for (int i = 0; i < n; ++i)
{
per[i]=i;
cte[i]=i;
cin>>tab[i];
}
bool vis[n];
shuffle(cte.begin(),cte.end(),rng);
memset(vis,0,sizeof vis);
int cnt=0;
for (int i = 0; i < n/2; ++i)
{
if(vis[cte[i]]==1) continue;
shuffle(per.begin(),per.end(),rng);
for (int j = 0; j < n; ++j)
{
if(per[j]==cte[i]) continue;
int cur=0;
for (int t = 0; t < m; ++t)
{
if(tab[cte[i]][t]!=tab[per[j]][t]) cur++;
if(cur>k) break;
}
if(cur!=k){
vis[per[j]]=1;
vis[cte[i]]=1;
break;
}
}
if(vis[cte[i]]==0){
cout <<cte[i]+1<<endl;
return 0;
}
}
for (int i = 0; i < n; ++i)
{
if(vis[cte[i]]==0){
cout <<cte[i]+1<<endl;
return 0;
}
}
}
Compilation message (stderr)
genetics.cpp: In function 'int main()':
genetics.cpp:26:9: warning: unused variable 'cnt' [-Wunused-variable]
26 | int cnt=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... |