# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421095 | nicolaalexandra | Genetics (BOI18_genetics) | C++14 | 988 ms | 101084 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 DIM 4200
#pragma GCC optimize("Ofast")
using namespace std;
char s[DIM];
int a[DIM][DIM];
long long sum[DIM][DIM],r[DIM];
int n,m,k,i,j;
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>n>>m>>k;
for (i=1;i<=n;i++){
cin>>s+1;
for (j=1;j<=m;j++){
if (s[j] == 'A')
a[i][j] = 1;
if (s[j] == 'C')
a[i][j] = 2;
if (s[j] == 'G')
a[i][j] = 3;
if (s[j] == 'T')
a[i][j] = 4;
}
}
long long total = 0;
for (i=1;i<=n;i++){
r[i] = rand();
total += r[i];
for (j=1;j<=m;j++)
sum[j][a[i][j]] += r[i];
}
for (i=1;i<=n;i++){
long long val = 0;
for (j=1;j<=m;j++)
val += total - sum[j][a[i][j]];
if (val == 1LL * k * (total - r[i])){
cout<<i;
break;
}
}
/*for (int pas=1;pas<=4;pas++){
for (i=1;i<=n;i++){
v[i].reset();
for (j=1;j<=m;j++){
if (a[i][j] == ch[pas])
v[i][j] = 1;
}}
for (i=1;i<=n;i++)
for (j=i+1;j<=n;j++){
int val = (v[i] & v[j]).count();
//int val = __builtin_popcount (v[i] & v[j]);
cnt[i][j] += val;
cnt[j][i] += val;
}
}
for (i=1;i<=n;i++){
int ok = 1;
for (j=1;j<=n;j++)
if (i != j && cnt[i][j] != m - k){
ok = 0;
break;
}
if (ok){
cout<<i;
break;
}
}
*/
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... |