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;
#define read freopen("acpc.in","r",stdin);
#define LESSGO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N=1801,M=505,OO=1e16,mod=1e9+9;
int n,m,d,onB[N],offB[N],dis[N];
string a[N];
int solve(){
for(int i=0;i<n;++i){
int cnt=0;
for(int j=0;j<n;++j){
if(i==j) continue;
int diff=0;
for(int k=0;k<m;++k){
if(a[i][k]!=a[j][k]) ++diff;
}
if(diff==d) ++cnt;
}
if(cnt==n-1) return i+1;
}
return 0;
}
int main(){
cin>>n>>m>>d;
for(int i=0;i<n;++i) cin>>a[i];
if(n<=100){
cout<<solve()<<"\n";
return 0;
}
bitset<N>s[N];
for(int i=0;i<n;++i){
for(int j=0;j<m;++j){
if(a[i][j]=='A') s[i][j]=1;
}
}
for(int i=0;i<n;++i){
int cnt=0;
for(int j=0;j<n;++j){
if(i==j) continue;
bitset<N>tmp=(s[i]^s[j]);
if(tmp.count()==d) ++cnt;
}
if(cnt==n-1){
cout<<i+1<<"\n";
return 0;
}
}
}
Compilation message (stderr)
genetics.cpp: In function 'int main()':
genetics.cpp:43:27: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
43 | if(tmp.count()==d) ++cnt;
| ~~~~~~~~~~~^~~
# | 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... |