# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
917935 | tnun | Mutating DNA (IOI21_dna) | C++17 | 30 ms | 6332 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;
#define ll long long
#define pb push_back
const int maxn=100006;
int CA[maxn]={0};
int AC[maxn]={0};
int TA[maxn]={0};
int AT[maxn]={0};
int TC[maxn]={0};
int CT[maxn]={0};
void init(string a,string b){
string a1="P"+a;
string b1="P"+b;
for(int i=1;i<=a.length();i++){
CA[i]=CA[i-1];
TA[i]=TA[i-1];
CT[i]=CT[i-1];
TC[i]=TC[i-1];
AT[i]=AT[i-1];
AC[i]=AC[i-1];
if(a1[i]=='A' && b1[i]=='C'){
AC[i]++;
}
if(a1[i]=='T' && b1[i]=='C'){
TC[i]++;
}
if(a1[i]=='A' && b1[i]=='T'){
AT[i]++;
}
if(a1[i]=='T' && b1[i]=='A'){
TA[i]++;
}
if(a1[i]=='C' && b1[i]=='T'){
CT[i]++;
}
if(a1[i]=='C' && b1[i]=='A'){
CA[i]++;
}
}
}
int get_distance(int x,int y){
x++;
y++;
int sum=0;
int ca1=CA[y]-CA[x-1];
int ac1=AC[y]-AC[x-1];
int ta1=TA[y]-TA[x-1];
int at1=AT[y]-AT[x-1];
int ct1=CT[y]-CT[x-1];
int tc1=TC[y]-TC[x-1];
int temp=min(ca1,ac1);
ca1-=temp; ac1-=temp;
sum+=temp;
temp=min(ta1,at1);
ta1-=temp; at1-=temp;
sum+=temp;
temp=min(tc1,ct1);
tc1-=temp; ct1-=temp;
sum+=temp;
temp=min(tc1,min(ca1,at1));
sum+=temp*2;
tc1-=temp;
ca1-=temp;
at1-=temp;
temp=min(ta1,min(ac1,ct1));
sum+=temp*2;
ta1-=temp;
ac1-=temp;
ct1-=temp;
if(ta1!=0 || at1!=0 || tc1!=0 || ct1!=0 || ac1!=0 || ca1!=0){
return -1;
}else{
return sum;
}
}
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... |