#include <bits/stdc++.h>
using namespace std;
int uc[4][4107],k,m;
long long arr[4107][4107],ars[4107][1000];
bool c[4107],ps;
bool check(int a,int b)
{
int x=0;
for(int i=0;i<=(ps?(m-1)/16:(m-1)/64);i++) x+=__builtin_popcountll(ars[a][i] xor ars[b][i]);
if(ps) x/=2;
if(x==k) return true;
return false;
}
int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n>>m>>k;
string s;
for(int i=0;i<n;i++)
{
cin>>s;
for(int j=0;j<m;j++)
{
if(s[j]=='A') arr[i][j]=0;
if(s[j]=='C') arr[i][j]=1;
if(s[j]=='G') arr[i][j]=2;
if(s[j]=='T') arr[i][j]=3;
if(arr[i][j]>1) ps=true;
uc[arr[i][j]][j]++;
}
}
if(!ps) for(int i=0;i<n;i++) for(int j=0;j<m;j++) ars[i][j/64]+=(arr[i][j]<<(j%64));
else for(int i=0;i<n;i++) for(int j=0;j<m;j++) ars[i][j/16]+=(1LL<<(arr[i][j]+(j%16)*4));
int x=0,y=1;
mt19937 rng(225522);
/*for(int ttt=0;ttt<400000;ttt++)
{
x=uniform_int_distribution<int>(0, n-1)(rng),y=uniform_int_distribution<int>(0,n-1)(rng);
if(x==y) continue;
int st=0;
if(!check(x,y)) {c[x]=c[y]=true;};
}*/
for(int i=0;i<n;i++) if(!c[i])
{
int skor=0;
bool propo=false;
for(int j=0;j<40;j++)
{
y=uniform_int_distribution<int>(0, n-1)(rng);
if(i==y) continue;
if(!check(i,y)) {c[i]=c[y]=true;}
}
if(c[i]) continue;
for(int j=0;j<m;j++) skor+=(n-uc[arr[i][j]][j]);
if(skor!=(n-1)*k) continue;
for(int j=0;j<500;j++)
{
y=uniform_int_distribution<int>(0, n-1)(rng);
if(i==y) continue;
if(!check(i,y)) {propo=true; c[y]=true; break;}
}
if(propo) continue;
printf("%d",i+1);
return 0;
}
}
Compilation message
genetics.cpp: In function 'int main()':
genetics.cpp:35:6: warning: unused variable 'x' [-Wunused-variable]
int x=0,y=1;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1144 KB |
Output is correct |
2 |
Correct |
5 ms |
1272 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
1020 KB |
Output is correct |
5 |
Correct |
6 ms |
1144 KB |
Output is correct |
6 |
Correct |
5 ms |
1144 KB |
Output is correct |
7 |
Correct |
5 ms |
760 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
1272 KB |
Output is correct |
11 |
Correct |
5 ms |
1144 KB |
Output is correct |
12 |
Correct |
5 ms |
1272 KB |
Output is correct |
13 |
Correct |
5 ms |
1272 KB |
Output is correct |
14 |
Correct |
5 ms |
1272 KB |
Output is correct |
15 |
Correct |
5 ms |
1272 KB |
Output is correct |
16 |
Correct |
5 ms |
1144 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
59 ms |
34040 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
59 ms |
34040 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1144 KB |
Output is correct |
2 |
Correct |
5 ms |
1272 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
1020 KB |
Output is correct |
5 |
Correct |
6 ms |
1144 KB |
Output is correct |
6 |
Correct |
5 ms |
1144 KB |
Output is correct |
7 |
Correct |
5 ms |
760 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
1272 KB |
Output is correct |
11 |
Correct |
5 ms |
1144 KB |
Output is correct |
12 |
Correct |
5 ms |
1272 KB |
Output is correct |
13 |
Correct |
5 ms |
1272 KB |
Output is correct |
14 |
Correct |
5 ms |
1272 KB |
Output is correct |
15 |
Correct |
5 ms |
1272 KB |
Output is correct |
16 |
Correct |
5 ms |
1144 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
18 |
Incorrect |
59 ms |
34040 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |