이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
int cnt[2][3][N],dp[9][N];
map<char,int> mp;
void init(string a, string b){
int i,j;
mp['A']=0;
mp['C']=1;
mp['T']=2;
a=' '+a;
b=' '+b;
for(i=1;i<a.size();i++){
for(j=0;j<3;j++)cnt[0][j][i]=cnt[0][j][i-1];
cnt[0][mp[a[i]]][i]++;
}
for(i=1;i<b.size();i++){
for(j=0;j<3;j++)cnt[1][j][i]=cnt[1][j][i-1];
cnt[1][mp[b[i]]][i]++;
}
for(i=1;i<a.size();i++){
for(j=0;j<9;j++)dp[j][i]=dp[j][i-1];
dp[mp[a[i]]*3+mp[b[i]]][i]++;
}
}
int get_distance(int x,int y){
int i,j,a,b,mi,sum=0,ans=0;
x++,y++;
for(i=0;i<3;i++)if(cnt[0][i][y]-cnt[0][i][x-1]!=cnt[1][i][y]-cnt[1][i][x-1])return -1;
for(i=0;i<3;i++)for(j=i+1;j<3;j++){
a=i*3+j;
b=j*3+i;
mi=min(dp[a][y]-dp[a][x-1],dp[b][y]-dp[b][x-1]);
ans+=mi;
sum+=dp[a][y]-dp[a][x-1]+dp[b][y]-dp[b][x-1];
}
return ans+(sum-2*mi)/3*2;
}
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:17:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for(i=1;i<a.size();i++){
| ~^~~~~~~~~
dna.cpp:21:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(i=1;i<b.size();i++){
| ~^~~~~~~~~
dna.cpp:25:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(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... |