# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
670536 | Marszpace | Mutating DNA (IOI21_dna) | C++17 | 39 ms | 7852 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;
vector<int> diff;
vector<int> aCountA,bCountA,aCountT,bCountT,aCountC,bCountC;
void init(string a, string b){
if(a[0]!=b[0]){
diff.push_back(1);
}
else{
diff.push_back(0);
}
for(int i=1;i<a.size();i++){
if(a[i]!=b[i]){
diff.push_back(diff[i-1]+1);
}
else{
diff.push_back(diff[i-1]);
}
}
if(a[0]=='A'){
aCountA.push_back(1);
aCountT.push_back(0);
aCountC.push_back(0);
}
else if(a[0]=='T'){
aCountA.push_back(0);
aCountT.push_back(1);
aCountC.push_back(0);
}
else{
aCountA.push_back(0);
aCountT.push_back(0);
aCountC.push_back(1);
}
if(b[0]=='A'){
bCountA.push_back(1);
bCountT.push_back(0);
bCountC.push_back(0);
}
else if(b[0]=='T'){
bCountA.push_back(0);
bCountT.push_back(1);
bCountC.push_back(0);
}
else{
bCountA.push_back(0);
bCountT.push_back(0);
bCountC.push_back(1);
}
for(int i=1;i<a.size();i++){
if(a[i]=='A'){
aCountA.push_back(aCountA[i-1]+1);
aCountT.push_back(aCountT[i-1]);
aCountC.push_back(aCountC[i-1]);
}
else if(a[i]=='T'){
aCountA.push_back(aCountA[i-1]);
aCountT.push_back(aCountT[i-1]+1);
aCountC.push_back(aCountC[i-1]);
}
else{
aCountA.push_back(aCountA[i-1]);
aCountT.push_back(aCountT[i-1]);
aCountC.push_back(aCountC[i-1]+1);
}
if(b[i]=='A'){
bCountA.push_back(bCountA[i-1]+1);
bCountT.push_back(bCountT[i-1]);
bCountC.push_back(bCountC[i-1]);
}
else if(b[i]=='T'){
bCountA.push_back(bCountA[i-1]);
bCountT.push_back(bCountT[i-1]+1);
bCountC.push_back(bCountC[i-1]);
}
else{
bCountA.push_back(bCountA[i-1]);
bCountT.push_back(bCountT[i-1]);
bCountC.push_back(bCountC[i-1]+1);
}
}
}
int get_distance(int x, int y){
x--;
bool condA = (aCountA[y]-aCountA[x])==(bCountA[y]-bCountA[x]);
bool condT = (aCountT[y]-aCountT[x])==(bCountT[y]-bCountT[x]);
bool condC = (aCountC[y]-aCountC[x])==(bCountC[y]-bCountC[x]);
//cout << endl << aCountA[y] << aCountA[x] << endl;
if(!condA||!condT||!condT){
return -1;
}
int res=diff[y]-diff[x];
return (res+1)/2;
}
// int main(){
// init("ATACAT", "ACTATA");
// cout << get_distance(1, 3) << " " << get_distance(4, 5) << " " << get_distance(3, 5);
// }
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... |