# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
130082 | TadijaSebez | Genetics (BOI18_genetics) | C++11 | 1080 ms | 84476 KiB |
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 <stdio.h>
#include <stdlib.h>
#include <ctime>
const int N=4115;
int my[N],sz[2],cnt[2][4][N];
char s[N][N];
int val[N][N];
bool ok[N];
int oks;
void Try(int n, int m, int k)
{
int i,j;
for(j=1;j<=m;j++) for(i=0;i<4;i++) cnt[0][i][j]=cnt[1][i][j]=0;
sz[0]=sz[1]=0;
for(i=1;i<=n;i++)
{
my[i]=rand()&1;
sz[my[i]]++;
for(j=1;j<=m;j++) cnt[my[i]][val[i][j]][j]++;
}
for(i=1;i<=n;i++)
{
if(ok[i])
{
int po[2];
po[0]=po[1]=0;
for(j=1;j<=m;j++)
{
po[0]+=sz[0]-cnt[0][val[i][j]][j];
po[1]+=sz[1]-cnt[1][val[i][j]][j];
}
sz[my[i]]--;
if(po[0]!=sz[0]*k) ok[i]=0,oks--;
else if(po[1]!=sz[1]*k) ok[i]=0,oks--;
sz[my[i]]++;
}
}
}
int main()
{
srand(time(0));
int n,m,k,i,j;
scanf("%i %i %i",&n,&m,&k);
for(i=1;i<=n;i++) scanf("%s",s[i]+1),ok[i]=1;
for(i=1;i<=n;i++) for(j=1;j<=m;j++)
{
if(s[i][j]=='A') val[i][j]=0;
if(s[i][j]=='C') val[i][j]=1;
if(s[i][j]=='G') val[i][j]=2;
if(s[i][j]=='T') val[i][j]=3;
}
oks=n;
while(oks>1) Try(n,m,k);
int ans=0;
for(i=1;i<=n;i++) if(ok[i]) ans=i;
printf("%i\n",ans);
return 0;
}
Compilation message (stderr)
# | 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... |