# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
923430 | Marszpace | DNA 돌연변이 (IOI21_dna) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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(long long 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(long long 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(long long x, long long 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||!condC){
return -1;
}
long long res=diff[y]-diff[x];
return (res+1)/2;
}