# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202905 | admin | Genetics (BOI18_genetics) | C++14 | 371 ms | 17272 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;
const int N = (int)1e4 + 2;
ll p[N], k, sum[N][5], cur = 0, ss, ssum[N];
int n, m;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int Code(char c) {
if(c == 'A') return 1;
if(c == 'C') return 2;
if(c == 'T') return 3;
return 0;
}
int main() {
scanf("%d%d%d",&n,&m,&k);vector<string> s(n + 2);
for(int i = 1; i <= n; ++i) {
static char tmp[1000000];
scanf("%s", tmp);
s[i] = tmp;
}//cin >> s[i];
int step = 10;
while(step --) {
for(int i = 1; i <= n; ++i) {
p[i] = uniform_int_distribution<ll>((ll)1e10, (ll)1e11)(rng);
for(int j = 0; j < m; ++j) sum[j][Code(s[i][j])] += p[i];
cur += p[i] * 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][Code(s[i][j])]);
if(cur - p[i] * k == ss) return cout << i, 0;
}
if(step == 0) return cout << n, 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... |