# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202664 | karma | Genetics (BOI18_genetics) | C++14 | 230 ms | 67064 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 ll long long
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
//#define int int64_t
using namespace std;
typedef pair<ll, ll> pii;
typedef unsigned long long int ui;
const int N = 4103;
const ui base = 13;
ui p[N], sum[N][4], ssum[N];
int n, m, k, a[N][N];
string s;
int Code(char c) {
if(c == 'A') return 1;
if(c == 'C') return 2;
if(c == 'T') return 3;
return 0;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define FileName "test"
if(fopen(FileName".inp", "r")) {
freopen(FileName".inp", "r", stdin);
freopen(FileName".out", "w", stdout);
}
cin >> n >> m >> k; p[0] = 1;
ui cur = 0, ss;
for(int i = 1; i <= n; ++i) {
p[i] = p[i - 1] * base;
cin >> s;
for(int j = 0; j < m; ++j) {
a[i][j] = Code(s[j]);
sum[j][a[i][j]] += p[i];
}
cur += p[i] * (ui)k;
}
for(int i = 0; i < m; ++i) {
ssum[i] = 0;
for(int j = 0; j < 4; ++j) ssum[i] += sum[i][j];
}
for(int i = 1; i <= n; ++i) {
ss = 0;
for(int j = 0; j < m; ++j) ss += (ssum[j] - sum[j][a[i][j]]);
if(cur == ss + p[i] * (ui)k) return cout << i, 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... |