# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647396 | tvladm2009 | Genetics (BOI18_genetics) | C++14 | 438 ms | 40372 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 ll = long long;
int const nmax = 4100;
int const sigma = 257;
int const modulo = 1e9 + 7;
std::string s[1 + nmax];
int r[1 + nmax], code[sigma], cost[1 + nmax][sigma];
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
srand(time(0));
int n, m, k;
std::cin >> n >> m >> k;
code['A'] = 0;
code['G'] = 1;
code['C'] = 2;
code['T'] = 3;
ll sum = 0;
for(int i = 1;i <= n; i++) {
std::cin >> s[i];
r[i] = rand() % modulo;
sum += r[i];
for(int j = 0;j < m; j++) {
cost[j][code[s[i][j]]] += r[i];
cost[j][code[s[i][j]]] %= modulo;
}
}
for(int i = 1;i <= n; i++) {
ll aux = (sum - r[i] + modulo) % modulo;
aux *= k;
aux %= modulo;
for(int j = 0;j < m; j++) {
for(int c = 0;c < 4; c++) {
if(c == code[s[i][j]])
continue;
aux -= cost[j][c];
if(aux < 0)
aux += modulo;
}
}
if(aux == 0) {
std::cout << i << "\n";
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... |