This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dna.h"
#include<iostream>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
const int MAXN = 100010;
int assi[255];
int n, arr[MAXN], brr[MAXN];
int tr[MAXN][3][3], aux[3][3], cha[3];
void init(std::string a, std::string b) {
n = (int)a.size();
assi['A']=0, assi['C']=1, assi['T']=2;
forn(i, n){
arr[i]=assi[a[i]], brr[i]=assi[b[i]];
tr[i+1][arr[i]][brr[i]]=1;
}
forn(i, n) forn(j, 3) forn(k, 3) tr[i+1][j][k]+=tr[i][j][k];
}
int get_distance(int x, int y) {
forn(i, 3) forn(j, 3) aux[i][j] = tr[y+1][i][j] - tr[x][i][j];
forn(i, 3) cha[i]=0;
forn(i, 3) forn(j, 3) cha[i]+=aux[i][j]-aux[j][i];
if(cha[0] || cha[1] || cha[2]) return -1;
int ret=0;
forn(i, 3) ret+=min(aux[i][(i+1)%3], aux[(i+1)%3][i]);
ret+=2*abs(aux[0][1]-aux[1][0]);
return ret;
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:15:19: warning: array subscript has type 'char' [-Wchar-subscripts]
15 | arr[i]=assi[a[i]], brr[i]=assi[b[i]];
| ^
dna.cpp:15:38: warning: array subscript has type 'char' [-Wchar-subscripts]
15 | arr[i]=assi[a[i]], brr[i]=assi[b[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... |