# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
443804 | fuad27 | Mutating DNA (IOI21_dna) | C++17 | 39 ms | 4980 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 a, b;
vector<int> prefix;
vector<int> prefA;
vector<int> prefB;
void init(string A, string B) {
a = A;
b = B;
prefix.resize(A.length()+1, 0);
prefA.resize(A.length() +1, 0);
prefB.resize(A.length() +1, 0);
for(int i = 0;i<A.length();i++) {
if(A[i] != B[i]) {
prefix[i+1] = prefix[i] + 1;
}
else {
prefix[i+1] = prefix[i];
}
if(A[i] == A[0]) {
prefA[i+1] = prefA[i] + 1;
}
else {
prefA[i+1] - prefA[i] - 1;
}
if(B[i] == A[0]) {
prefB[i+1] = prefB[i] + 1;
}
else {
prefB[i+1] = prefB[i] - 1;
}
}
}
int get_distance(int x, int y) {
if(prefA[y+1] - prefA[x] != prefB[y+1] - prefB[x]) {
return -1;
}
return (prefix[y+1] - prefix[x])/2;
}
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... |