# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
807722 | vjudge1 | Mutating DNA (IOI21_dna) | C++17 | 32 ms | 7400 KiB |
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"
using namespace std;
int dp[100100][3][3];
void init(string a, string b) {
string key = "ACT";
for(int i = 1; i <= a.size(); i++)
for(int j = 0; j < 3; j++)
for(int k = 0; k < 3; k++)
dp[i][j][k]=dp[i-1][j][k]+(a[i-1]==key[j]&&b[i-1]==key[k]);
}
int get_distance(int l, int r) {
int ans=0,prev=0;
for(int i = 0; i < 3; i++) {
int next = (i+1)%3;
int x = dp[r+1][i][next]-dp[l][i][next],y=dp[r+1][next][i]-dp[l][next][i];
if(i){
if(prev!=x-y) return -1;
} else
ans+=2*abs(prev=x-y);
ans+=min(x,y);
}
return ans;
}
Compilation message (stderr)
# | 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... |