# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203081 | quocnguyen1012 | Genetics (BOI18_genetics) | C++14 | 683 ms | 82808 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 fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7, maxn = 4105, base = 131;
int f[maxn][5];
int a[maxn][maxn];
int N, M, K;
int POW[maxn];
int to(char x)
{
if (x == 'A') return 1;
if (x == 'C') return 2;
if (x == 'G') return 3;
else return 4;
}
signed main(void)
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen("A.INP", "r")){
freopen("A.INP", "r", stdin);
freopen("A.OUT", "w", stdout);
}
POW[0] = 1;
for (int i = 1; i < maxn; ++i){
POW[i] = 1ll * POW[i - 1] * base % mod;
}
cin >> N >> M >> K;
for (int i = 1; i <= N; ++i){
for (int j = 1; j <= M; ++j){
char x; cin >> x;
a[i][j] = to(x);
f[j][a[i][j]] += POW[i];
f[j][a[i][j]] %= mod;
}
}
for (int i = 1; i <= N; ++i){
ll need = 0, cur = 0;
for (int j = 1; j <= N; ++j){
if (j != i) need += 1ll * K * POW[j] % mod;
}
for (int j = 1; j <= M; ++j){
for (int k = 1; k <= 4; ++k){
if (k != a[i][j]){
cur += f[j][k];
}
}
}
need %= mod; cur %= mod;
if (cur == need){
cout << 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... |