# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
607240 | wiktorlew | Mutating DNA (IOI21_dna) | C++17 | 38 ms | 6032 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>
using namespace std;
const int N = 2e5 + 5;
int ile[N][3][2], line[N][3];
int tsf(char c){
if(c=='A') return 0;
if(c=='C') return 1;
if(c=='T') return 2;
}
void init(string a, string b){
for(int i=0;i<a.length();i++){
ile[i+1][tsf(a[i])][0]++;
ile[i+1][tsf(b[i])][1]++;
if((a[i]=='A'&&b[i]=='C')||(a[i]=='C'&&b[i]=='A')) line[i+1][0]++;
if((a[i]=='A'&&b[i]=='T')||(a[i]=='T'&&b[i]=='A')) line[i+1][1]++;
if((a[i]=='C'&&b[i]=='T')||(a[i]=='T'&&b[i]=='C')) line[i+1][2]++;
for(int j=0;j<=2;j++){
ile[i+1][j][0]+=ile[i][j][0];
ile[i+1][j][1]+=ile[i][j][1];
line[i+1][j]+=line[i][j];
}
}
}
int get_distance(int x, int y){
x++;
y++;
if(ile[y][0][0]-ile[x-1][0][0]!=ile[y][0][1]-ile[x-1][0][1]){
return -1;
}
if(ile[y][1][0]-ile[x-1][1][0]!=ile[y][1][1]-ile[x-1][1][1]){
return -1;
}
if(ile[y][2][0]-ile[x-1][2][0]!=ile[y][2][1]-ile[x-1][2][1]){
return -1;
}
int wynik=0, err=0;
for(int i=0;i<=2;i++){
int pom = line[y][i]-line[x-1][i];
wynik+=pom/2;
if(pom%2) err++;
}
wynik+=(err/3)*2;
return wynik;
}
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... |