# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
553966 | Vladth11 | Genetics (BOI18_genetics) | C++14 | 418 ms | 36408 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 debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;
const ll NMAX = 4101;
const ll VMAX = 1001;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 447;
const ll base = 31;
const ll nr_of_bits = 19;
ll n, m, k;
string s[NMAX];
ll w[NMAX];
ll cost[NMAX][4];
ll total = 0;
int cod(char L){
if(L == 'A') return 0;
if(L == 'G') return 1;
if(L == 'C') return 2;
if(L == 'T') return 3;
}
int main() {
srand(time(0));
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int i;
cin >> n >> m >> k;
for(i = 1; i <= n; i++){
cin >> s[i];
w[i] = rand() % MOD;
total += w[i];
total %= MOD;
for(int j = 0; j < m; j++){
cost[j][cod(s[i][j])] += w[i];
cost[j][cod(s[i][j])] %= MOD;
}
}
for(i = 1; i <= n; i++){
ll target = (total - w[i] + MOD) % MOD;
target *= k;
target %= MOD;
for(int j = 0; j < m; j++){
for(int t = 0; t < 4; t++){
if(t == cod(s[i][j])) continue;
target = target - cost[j][t];
if(target < 0)
target += MOD;
}
}
if(target == 0){
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... |