이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
#include "dna.h"
typedef long long ll;
using namespace std;
const int mxN=1e5+5;
int d[100005];
int numbersA[mxN][3], numbersB[mxN][3];
int n,q,x,y;
string f,s;
int aa=0, ta=0, ca=0,ab=0, tb=0, cb=0, difference=0;
void init(string a, string b)
{
for(int i=0; i<=a.size(); i++)
{
for(int j=0; j<3; j++)
{
numbersA[i][j]=0;
numbersB[i][j]=0;
}
}
for(int i=0; i<a.size(); i++)
{
if(a[i]!=b[i])
{
difference++;
}
d[i]=difference;
if(a[i]=='A')
{
aa++;
}
else if (a[i]=='T')
{
ta++;
}
else if (a[i]=='C')
{
ca++;
}
numbersA[i][0]=aa;
numbersA[i][1]=ta;
numbersA[i][2]=ca;
if(b[i]=='A')
{
ab++;
}
else if (b[i]=='T')
{
tb++;
}
else if (b[i]=='C')
{
cb++;
}
numbersB[i][0]=ab;
numbersB[i][1]=tb;
numbersB[i][2]=cb;
}
}
int get_distance(int x,int y)
{
int div=d[y];
int da1=numbersA[y][0], dt1=numbersA[y][1], dc1=numbersA[y][2], da2=numbersB[y][0], dt2=numbersB[y][1], dc2=numbersB[y][2] ;
if(x!=0)
{
div-=d[x-1];
da1-=numbersA[x-1][0];
dt1-=numbersA[x-1][1];
dc1-=numbersA[x-1][2];
da2-=numbersB[x-1][0];
dt2-=numbersB[x-1][1];
dc2-=numbersB[x-1][2];
}
if(da1==da2 && dt1==dt2 && dc1==dc2)
{
return ceil((double)div/(double)2);
}
else
{
return -1;
}
}
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:20:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for(int i=0; i<=a.size(); i++)
| ~^~~~~~~~~~
dna.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i=0; 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... |