# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202894 | karma | Genetics (BOI18_genetics) | C++14 | 467 ms | 17144 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>
#define MOD 1000000007
using namespace std;
long long sum[4110][5];
char a[4110][4110];
int convert (char c){
if (c == 'A')
return 0;
if (c == 'C')
return 1;
if (c == 'G')
return 2;
return 3;
}
int check (int x , int n , int m, int k){
int i , j , dif;
for (i=1;i<=n;i++){
if (i == x)
continue;
dif = 0;
for (j=1;j<=m;j++){
if (a[x][j] != a[i][j])
dif++;
if (dif > k)
return 0;
}
if (dif != k)
return 0;
}
return 1;
}
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , m , k , i , j , curr , summ;
fscanf (fin,"%d%d%d\n",&n,&m,&k);
for (i=1;i<=n;i++){
fgets (a[i] + 1 , 5000 , fin);
for (j=1;j<=m;j++){
sum[j][convert(a[i][j])] = (sum[j][convert(a[i][j])] + i)%MOD;
}
}
for (curr = 1 ; curr <= n ; curr ++){
summ = 0;
for (i=1;i<=m;i++){
summ = (summ + sum[i][0] + sum[i][1] + sum[i][2] + sum[i][3])%MOD;
summ = ((summ - sum[i][convert(a[curr][i])]) % MOD + MOD )%MOD;
}
if (summ == (((long long) k * ( ( ((long long)n * (n+1)) / 2 ) %MOD - curr)%MOD )%MOD + MOD)%MOD && check(curr , n, m , k)) {
fprintf (fout,"%d ",curr);
return 0;
}
}
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... |