이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cerr<<vars<<" = ";
string delim="";
(...,(cerr<<delim<<values,delim=", "));
cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif
#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mxN=1e5+5; //make sure this is right
const int mod=1e9+7;
int f[mxN][3][2],id[1000],n,cnt[mxN][3];
void init(string a,string b){
id['A']=0;
id['C']=1;
id['T']=2;
n=sz(a);
for(int i=1;i<=n;i++){
for(int j=0;j<3;j++){
if(id[a[i-1]]==j)
f[i][j][0]=f[i-1][j][0]+1;
else
f[i][j][0]=f[i-1][j][0];
if(id[b[i-1]]==j)
f[i][j][1]=f[i-1][j][1]+1;
else
f[i][j][1]=f[i-1][j][1];
cnt[i][j]+=cnt[i-1][j];
}
if(minmax({a[i-1],b[i-1]})==minmax({'A','C'}))
cnt[i][0]++;
else if(minmax({a[i-1],b[i-1]})==minmax({'A','T'}))
cnt[i][1]++;
else if(minmax({a[i-1],b[i-1]})==minmax({'C','T'}))
cnt[i][2]++;
}
}
int get_distance(int x,int y){
y++;
for(int i=0;i<3;i++){
if(f[y][i][0]-f[x][i][0]!=f[y][i][1]-f[x][i][1])
return -1;
}
int a1=cnt[y][0]-cnt[x][0];
int a2=cnt[y][1]-cnt[x][1];
int a3=cnt[y][2]-cnt[x][2];
int ans=0;
int m=min(a1,a2);
ans+=m;
a1-=m;
m=min(a2,a3);
ans+=m; a2-=m; a3-=m;
ans+=(a1+a2+a3)/2;
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:41:25: warning: array subscript has type 'char' [-Wchar-subscripts]
41 | if(id[a[i-1]]==j)
| ^
dna.cpp:45:25: warning: array subscript has type 'char' [-Wchar-subscripts]
45 | if(id[b[i-1]]==j)
| ^
# | 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... |