# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
213441 | MKopchev | Genetics (BOI18_genetics) | C++14 | 1423 ms | 54396 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<bits/stdc++.h>
using namespace std;
const int nmax=4100+42,SZ=16,LIM=1<<SZ;
int n,m,k;
char inp[nmax][nmax];
char in()
{
char c=getchar();
while(c!='A'&&c!='C'&&c!='G'&&c!='T')c=getchar();
return c;
}
int seen[4][nmax];
int hsh(char c)
{
if(c=='A')return 0;
if(c=='C')return 1;
if(c=='G')return 2;
return 3;
}
unsigned int hsh_values[nmax][nmax];
int bits_in[LIM];
int ask(unsigned int val)
{
return bits_in[val/LIM]+bits_in[val%LIM];
}
void test(int bad)
{
for(int i=1;i<=n;i++)
if(i!=bad)
{
int diff=0;
for(int j=0;j<=m/SZ;j++)
diff=diff+ask(hsh_values[i][j]^hsh_values[bad][j]);
if(diff!=k)return;
}
printf("%i\n",bad);
exit(0);
}
int main()
{
scanf("%i%i%i",&n,&m,&k);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
inp[i][j]=in();
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
seen[hsh(inp[i][j])][j]++;
hsh_values[i][j/SZ]=hsh_values[i][j/SZ]*4+hsh(inp[i][j]);
}
for(int i=0;i<LIM;i++)
{
int i_=i;
while(i_)
{
bits_in[i]+=(i_%4!=0);
i_=i_/4;
}
}
for(int i=1;i<=n;i++)
{
int total_diff=0;
for(int j=1;j<=m;j++)
total_diff+=seen[0][j]+seen[1][j]+seen[2][j]+seen[3][j]-seen[hsh(inp[i][j])][j];
if(total_diff==k*(n-1))test(i);
}
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... |