# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
734512 | Roman70 | Mutating DNA (IOI21_dna) | C++17 | 79 ms | 30088 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 c,d;
const int sz = 1e5;
vector<vector<int>>prefix(sz,vector<int>(26,0));
vector<vector<int>>prefix1(sz,vector<int>(26,0));
vector<int>prefix2(sz);
void init(string a,string b) {
c = a;
d = b;
prefix[0][c[0] - 'A']++;
prefix1[0][d[0] - 'A']++;
// 65 67 84
if(c[0] != d[0]) prefix2[0]++;
for(int i = 1;i<c.size();i++){
prefix[i][c[i] - 'A']++;
prefix[i][0]+= prefix[i-1][0];
prefix[i][2]+= prefix[i-1][2];
prefix[i][19]+= prefix[i-1][19];
if(c[i] != d[i]) prefix2[i]++;
prefix2[i] += prefix2[i-1];
}
for(int i = 1;i<d.size();i++){
prefix1[i][d[i] - 'A']++;
prefix1[i][0]+= prefix1[i-1][0];
prefix1[i][2]+= prefix1[i-1][2];
prefix1[i][19]+= prefix1[i-1][19];
}
}
int get_distance(int x,int y){
int ans;
int cmp[2][26];
cmp[0][0] = prefix[y][0] - (x == 0 ? 0 : prefix[x-1][0]);
cmp[0][2]= prefix[y][2] - (x == 0 ? 0 : prefix[x-1][2]);
cmp[0][19]= prefix[y][19] - (x == 0 ? 0 : prefix[x-1][19]);
cmp[1][0]= prefix1[y][0] - (x == 0 ? 0 : prefix1[x-1][0]);
cmp[1][2]= prefix1[y][2] - (x == 0 ? 0 : prefix1[x-1][2]);
cmp[1][19]= prefix1[y][19] - (x == 0 ? 0 : prefix1[x-1][19]);
if(cmp[0][0] == cmp[1][0] && cmp[0][2] == cmp[1][2] && cmp[0][19] == cmp[1][19]) ans = (prefix2[y] - (x == 0 ? 0 : prefix2[x-1])) / 2 + (prefix2[y] - (x == 0 ? 0 : prefix2[x-1])) % 2;
else ans = -1;
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... |