This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define gen(arr,n,nxt) generate(arr,arr+n,nxt)
#define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0);
#define EPS 0.00000001
const int mo=1e9+7,INF=1e18;
int nxt(){int x;cin>>x;return x;}
signed main(){
Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty
//freopen("in.txt","r",stdin);
int n=nxt(),m=nxt(),k=nxt();
string dna[n];
for(int i=0;i<n;i++)cin>>dna[i];
int ans[n];
bool vis[n];
memset(vis,0,sizeof vis);
memset(ans,0,sizeof ans);
int mx =0;
int idx =0 ;
bool vis2[n][n];
memset(vis2,0,sizeof vis2);
for(int i=0;i<n;i++){
int c = 0;
if(vis[i] == 1)continue;
for(int j=i+1;j<n;j++){
int ok =0;
for(int a =0;a<m;a++)
ok += (dna[i][a]!=dna[j][a]);
vis2[i][j]=1;
vis2[j][i]=1;
ans[i] += ok == k;
ans[j] += ok == k;
if(ok != k)
vis[j] = 1,vis[i] =1;
}
}
vector<int>v,bad;
for(int i=0;i<n;i++){
if(!vis[i])v.push_back(i);
else bad.push_back(i);
}
for(int i=0;i<v.size();i++){
string s = dna[v[i]];
for(auto y:bad){
if(y > v[i])break;
if(vis2[v[i]][y])continue;
string s2 = dna[y];
int ok =0;
for(int a =0;a<m;a++)
ok += (s[a]!=s2[a]);
ans[v[i]]+= ok == k;
}
if(ans[v[i]] == n-1){
cout<<v[i]+1;
return 0;
}
}
cout<<idx+1;
return 0;
}
Compilation message (stderr)
genetics.cpp:21:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
21 | const int mo=1e9+7,INF=1e18;
| ^~~~
genetics.cpp: In function 'int main()':
genetics.cpp:39:13: warning: unused variable 'c' [-Wunused-variable]
39 | int c = 0;
| ^
genetics.cpp:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
genetics.cpp:34:9: warning: unused variable 'mx' [-Wunused-variable]
34 | int mx =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... |