# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1001629 | ayankarimova | Mutating DNA (IOI21_dna) | C++17 | 42 ms | 8712 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 "dna.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll sz= 100000+5;
ll p[sz][6];
void init(std::string a, std::string b) {
for(int i=0; i<a.size(); i++){
for(int j=0; j<6; j++) p[i][j]+=p[i-1][j];
if(a[i]=='A' && b[i]=='C') p[i][0]++;
if(a[i]=='A' && b[i]=='T') p[i][1]++;
if(a[i]=='C' && b[i]=='A') p[i][2]++;
if(a[i]=='C' && b[i]=='T') p[i][3]++;
if(a[i]=='T' && b[i]=='A') p[i][4]++;
if(a[i]=='T' && b[i]=='C') p[i][5]++;
}
}
int get_distance(int x, int y) {
ll ac=p[y][0]-p[x-1][0];
ll att=p[y][1]-p[x-1][1];
ll ca=p[y][2]-p[x-1][2];
ll ct=p[y][3]-p[x-1][3];
ll ta=p[y][4]-p[x-1][4];
ll tc=p[y][5]-p[x-1][5];
if(ac+att==ca+ta && ca+ct==ac+tc && ta+tc==att+ct){
ll a=min(ac, ca);
ll b=min(tc, ct);
ll c=min(ta, att);
ll res=ac+ca-2*a + tc+ct-2*b + att+ta - 2*c;
return a+b+c+res*2/3;
}
return -1;
}
/*
{} []
*/
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... |