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,unroll-loops")
#pragma GCC target("avx2,popcnt")
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
#define int short
const int mxn = 4100;
bitset<mxn> dp[mxn][5];
int N,M,K;
bitset<mxn> no;
int perm[mxn],pos[mxn];
int check[mxn][mxn];
main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M>>K;
for(int i = 0;i<N;i++)perm[i] = i;
srand(7123);
random_shuffle(perm,perm+N);
for(int i = 0;i<N;i++)pos[perm[i]] = i;
for(int i = 0;i<N;i++){
string s;
cin>>s;
int now = pos[i];
for(int j = 0;j<M;j++){
if(s[j] == 'A')dp[now][0][j] = 1;
else if(s[j] == 'T')dp[now][1][j] = 1;
else if(s[j] == 'G')dp[now][2][j] = 1;
else dp[now][3][j] = 1;
}
}
/*
for(int i = 0;i<N;i++){
cout<<i<<":"<<endl;
for(int j = 0;j<4;j++){
for(int k = 0;k<M;k++)cout<<dp[i][j][k];
cout<<endl;
}
cout<<endl;
}
*/
for(int i =0;i<N;i++){
if(no[i])continue;
bool flag = true;
for(int j = 0;j<N;j++){
if(i == j||check[i][j])continue;
if(((dp[i][0]^dp[j][0])|(dp[i][1]^(dp[j][1]))|(dp[i][2]^dp[j][2])|(dp[i][3]^dp[j][3])).count() != K){
flag = false;
no[i] = no[j] = true;
break;
}
else check[i][j] = check[j][i] = true;
}
if(flag){
cout<<perm[i]+1;
return 0;
}
}
assert(false);
}
Compilation message (stderr)
genetics.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
22 | main(){
| ^~~~
genetics.cpp: In function 'int main()':
genetics.cpp:56:99: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'short int' [-Wsign-compare]
56 | if(((dp[i][0]^dp[j][0])|(dp[i][1]^(dp[j][1]))|(dp[i][2]^dp[j][2])|(dp[i][3]^dp[j][3])).count() != K){
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# | 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... |