# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
689552 | Toxtaq | Mutating DNA (IOI21_dna) | C++17 | 33 ms | 4912 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<bits/stdc++.h>
#include "dna.h"
using namespace std;
struct ATC{
int A = 0, T = 0, C = 0;
};
vector<ATC>cnt_A, cnt_B;
vector<int>pref;
void init(string A, string B){
pref.resize(A.length() + 1);
cnt_A.resize(A.length() + 1);
cnt_B.resize(A.length() + 1);
for(int i = 1;i <= A.length();++i){
pref[i] = pref[i - 1];
if(A[i - 1] != B[i - 1])pref[i]++;
}
for(int i = 1;i <= A.length();++i){
cnt_A[i].A = cnt_A[i - 1].A;
cnt_A[i].T = cnt_A[i - 1].T;
cnt_A[i].C = cnt_A[i - 1].C;
if(A[i - 1] == 'A')cnt_A[i].A++;
if(A[i - 1] == 'T')cnt_A[i].T++;
if(A[i - 1] == 'C')cnt_A[i].C++;
}
for(int i = 1;i <= A.length();++i){
cnt_B[i].A = cnt_B[i - 1].A;
cnt_B[i].T = cnt_B[i - 1].T;
cnt_B[i].C = cnt_B[i - 1].C;
if(B[i - 1] == 'A')cnt_B[i].A++;
if(B[i - 1] == 'T')cnt_B[i].T++;
if(B[i - 1] == 'C')cnt_B[i].C++;
}
}
int get_distance(int x, int y){
x++;
y++;
int q = pref[y] - pref[x - 1];
ATC num1, num2;
num1.A = cnt_A[y].A - cnt_A[x - 1].A;
num1.T = cnt_A[y].T - cnt_A[x - 1].T;
num1.C = cnt_A[y].C - cnt_A[x - 1].C;
num2.A = cnt_B[y].A - cnt_B[x - 1].A;
num2.T = cnt_B[y].T - cnt_B[x - 1].T;
num2.C = cnt_B[y].C - cnt_B[x - 1].C;
// cout << num1.A << " " << num1.T << " " << num1.C << '\n';
// cout << num2.A << " " << num2.T << " " << num2.C;
if(num1.A != num2.A)return -1;
if(num1.T != num2.T)return -1;
if(num1.C != num2.C)return -1;
if(!q)return 0;
return q - 1;
}
//int main(){
// init("CTA", "ATC");
// cout << get_distance(0, 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... |