이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include<vector>
int n,q;
std::string s;
std::string c;
std::vector<int> A;
std::vector<int> B;
std::vector<int> C;
std::vector<int> D;
std::vector<int> E;
std::vector<int> F;
std::vector<int> G;
void init(std::string a, std::string b) {
n=a.length();
s=a,c=b;
A.push_back(0),B.push_back(0),C.push_back(0),D.push_back(0),E.push_back(0),F.push_back(0),G.push_back(0);
for(int i=0;i<n;i++){
if(a[i]!=b[i]){
A.push_back(1);
if(s[i]=='A'){
B.push_back(1);
C.push_back(0);
F.push_back(0);
}else if(s[i]=='C'){
C.push_back(1);
B.push_back(0);
F.push_back(0);
}else{
F.push_back(1);
B.push_back(0);
C.push_back(0);
}
if(c[i]=='A'){
D.push_back(1);
E.push_back(0);
G.push_back(0);
}else if(c[i]=='C'){
D.push_back(1);
E.push_back(0);
G.push_back(0);
}else{
G.push_back(1);
D.push_back(0);
E.push_back(0);
}
}else{
A.push_back(0);
B.push_back(0);
C.push_back(0);
D.push_back(0);
E.push_back(0);
F.push_back(0);
G.push_back(0);
}
}
for(int i=1;i<=n;i++){
A[i]+=A[i-1];
B[i]+=B[i-1];
C[i]+=C[i-1];
D[i]+=D[i-1];
E[i]+=E[i-1];
F[i]+=F[i-1];
G[i]+=G[i-1];
}
while(q--){
int x,y;
get_distance(x,y);
}
}
int get_distance(int x, int y) {
int j=A[y+1]-A[x],h1=B[y+1]-B[x],h2=D[y+1]-D[x],l1=C[y+1]-C[x],l2=E[y+1]-E[x];
if(h1==h2 && l1==l2){
if(j%2==1){
j+=1;
}
return j/2;
}else{
return -1;
}
}
//7 3
//ATATATA
//TATTATT
//1 5
//0 2
//0 6
//-1
//0
//-1
# | 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... |