이 제출은 이전 버전의 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(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||!condC){
return -1;
}
int res=diff[y]-diff[x];
return (res+1)/2;
}
//int main(){
// init("ATACAT", "ACTATA");
// cout << get_distance(0, 0) << " " << get_distance(0, 5) << " " << get_distance(3, 5);
//}
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(int i=1;i<a.size();i++){
| ~^~~~~~~~~
dna.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i=1;i<a.size();i++){
| ~^~~~~~~~~
# | 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... |