이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
vvi rui;
void init(std::string a, std::string b) {
ll n=a.size();
rui=vvi(6,vi(n+1));
rep(i,n)if(a[i]!=b[i]){
ll t;
if(a[i]=='A'&&b[i]=='C')t=0;
if(a[i]=='C'&&b[i]=='A')t=1;
if(a[i]=='C'&&b[i]=='T')t=2;
if(a[i]=='T'&&b[i]=='C')t=3;
if(a[i]=='T'&&b[i]=='A')t=4;
if(a[i]=='A'&&b[i]=='T')t=5;
rui[t][i+1]++;
}
rep(i,6)rep(j,n)rui[i][j+1]+=rui[i][j];
}
int get_distance(int x, int y) {
y++;
vi cnt(6);
rep(i,6)cnt[i]=rui[i][y]-rui[i][x];
ll ans=0;
rep(i,3){
ll t=min(cnt[i*2],cnt[i*2+1]);
ans+=t;
cnt[i*2]-=t;
cnt[i*2+1]-=t;
}
if(cnt[0]+cnt[2]+cnt[4]==0&&cnt[1]==cnt[3]&&cnt[3]==cnt[5])ans+=cnt[1]*2;
else if(cnt[1]+cnt[3]+cnt[5]==0&&cnt[0]==cnt[2]&&cnt[2]==cnt[4])ans+=cnt[0]*2;
else return -1;
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:24:8: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
24 | rui[t][i+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... |