# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824333 | lto5 | Genetics (BOI18_genetics) | C++14 | 256 ms | 35020 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;
mt19937_64 rng(time(NULL));
const int N = 4505;
char a[N][N];
int64_t h[N];
int mpp[256];
int64_t rows[N][4];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#define task "a"
if (fopen(task ".inp", "r")) {
freopen(task ".inp", "r", stdin);
freopen(task ".out", "w", stdout);
}
int n, m, k;
cin >> n >> m >> k;
int64_t all_rows = 0;
for (int i = 1; i <= n; i++) {
h[i] = uniform_int_distribution<int64_t>(1, 1e18)(rng);
all_rows += h[i];
}
mpp['A'] = 0, mpp['C'] = 1, mpp['T'] = 2, mpp['G'] = 3;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
rows[j][mpp[a[i][j]]] += h[i];
}
}
for (int i = 1; i <= n; i++) {
int64_t list_row = 0;
for (int j = 1; j <= m; j++) {
list_row += all_rows - rows[j][mpp[a[i][j]]];
}
if (list_row == (all_rows - h[i]) * k) {
cout << i;
return 0;
}
}
cout << -1;
return 0;
}
/*
list[j, c] = {i : a[i][j] = c}
for i = 1 -> n:
for j = 1 -> m:
c = a[i][j]
A = {}
for (c' = 0 -> c) if c != c' A.insert(all(list[j, c']))
check if [1, n] appear in A k times
*/
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... |