# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957838 | hirayuu_oj | Mutating DNA (IOI21_dna) | C++17 | 32 ms | 6424 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;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) x.begin(),x.end()
using ll=long long;
int cum[7][100010];
int get_type(char s,char t){
if(s=='A' and t=='T'){
return 0;
}
if(s=='T' and t=='A'){
return 1;
}
if(s=='A' and t=='C'){
return 2;
}
if(s=='C' and t=='A'){
return 3;
}
if(s=='T' and t=='C'){
return 4;
}
if(s=='C' and t=='T'){
return 5;
}
return 6;
}
void init(std::string a, std::string b) {
rep(i,7){
cum[i][0]=0;
}
rep(i,a.size()){
rep(j,7){
cum[j][i+1]=cum[j][i];
}
cum[get_type(a[i],b[i])][i+1]++;
}
}
int get_distance(int x, int y) {
int types[7];
rep(i,7){
types[i]=cum[i][y+1]-cum[i][x];
}
if(types[0]+types[2]!=types[1]+types[3]){
return -1;
}
if(types[1]+types[4]!=types[0]+types[5]){
return -1;
}
int ans=0;
rep(i,3){
int now=min(types[i*2],types[i*2+1]);
types[i*2]-=now;
types[i*2+1]-=now;
ans+=now;
}
ans+=max(types[0],types[1])*2;
return ans;
}
/*
at
ta
ag
ga
tg
gt
*/
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... |