# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957149 | DeltaStruct | Mutating DNA (IOI21_dna) | C++17 | 126 ms | 6472 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"
#include <bits/stdc++.h>
using namespace std;
string x,y,u="ACT"; int n; map<string,vector<int>> acc;
void init(string a,string b){
x = a,y = b,n = a.size();
for (auto c:u) for (auto d:u) if (c!=d){
string i = {c,d}; acc[i] = {0};
for (int k(0);k < n;++k) acc[i].emplace_back(acc[i].back()+(x[k]==c&&y[k]==d));
}
}
int get_distance(int l,int r){
++r;
auto sb = [&acc,&l,&r](string s,string t){return (acc[s][r]-acc[s][l])-(acc[t][r]-acc[t][l]); };
if (sb("AC","CA")!=sb("CT","TC")||sb("AC","CA")!=sb("TA","AT")) return -1;
int res = abs(sb("AC","CA"))*2;
for (int i(0);i < 3;++i) for (int k(i+1);k < 3;++k){
string s = {u[i],u[k]},t = {u[k],u[i]};
res += min(acc[s][r]-acc[s][l],acc[t][r]-acc[t][l]);
}
return res;
}
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... |