# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
697765 | hiikunZ | Mutating DNA (IOI21_dna) | C++17 | 61 ms | 18092 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;
using ll = long long int;
vector<vector<ll>> R(9,vector<ll>(200000,0));
void init(string a, string b){
ll N = (ll)a.size();
for(ll i = 0;i < N;i++){
ll p,q;
if(a[i] == 'A') p = 0;
if(a[i] == 'T') p = 1;
if(a[i] == 'C') p = 2;
if(b[i] == 'A') q = 0;
if(b[i] == 'T') q = 1;
if(b[i] == 'C') q = 2;
for(ll j = 0;j < 9;j++) R[j][i + 1] = R[j][i];
R[p * 3 + q][i + 1]++;
}
}
int get_distance(int x, int y){
y++;
ll ans = 0;
vector<int> A(9);
for(ll j = 0;j < 9;j++) A[j] = R[j][y] - R[j][x];
for(ll i = 0;i < 3;i++){
A[i * 3 + i] = 0;
for(ll j = i + 1;j < 3;j++){
ll k = min(A[i * 3 + j],A[j * 3 + i]);
A[i * 3 + j] -= k;
A[j * 3 + i] -= k;
ans += k;
}
}
vector<ll> C(3);
for(ll i = 0;i < 3;i++){
for(ll j = 0;j < 3;j++){
C[i] += A[i * 3 + j];
C[j] -= A[i * 3 + j];
}
}
if(C[0] != 0 || C[1] != 0 || C[2] != 0) return -1;
ll w = 0;
for(int i = 0;i < 1;i++){
for(int j = 0;j < 3;j++){
for(int k = 0;k < 3;k++){
if(i != j && i != k && j != k && A[i * 3 + j] == A[j * 3 + k] && A[i * 3 + j] == A[k * 3 + i]){
w += A[i * 3 + j] * 2;
}
}
}
}
return ans + w;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |