# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522130 | new_acc | Mutating DNA (IOI21_dna) | C++17 | 38 ms | 8004 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>
#define fi first
#define se second
#define rep(a, b) for(int a = 0; a < (b); a++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e5+10;
string a,b;
int pref[N][10];
void ob(char a,char b,int i){
rep(j,10) pref[i][j]=(i==0?0:pref[i-1][j]);
if(a=='A' and b=='C') pref[i][0]++;
if(a=='A' and b=='T') pref[i][1]++;
if(a=='C' and b=='T') pref[i][2]++;
if(a=='C' and b=='A') pref[i][3]++;
if(a=='T' and b=='A') pref[i][4]++;
if(a=='T' and b=='C') pref[i][5]++;
if(a=='T') pref[i][6]++;
if(a=='C') pref[i][7]++;
if(a=='A') pref[i][8]++;
if(b=='T') pref[i][6]--;
if(b=='C') pref[i][7]--;
if(b=='A') pref[i][8]--;
}
void init(string t1,string t2){
a=t1,b=t2;
rep(i,t1.size()) ob(t1[i],t2[i],i);
}
int get_distance(int x,int y){
if(pref[y][6]!=(x==0?0:pref[x-1][6]) or pref[y][7]!=(x==0?0:pref[x-1][7]) or pref[y][8]!=(x==0?0:pref[x-1][8])) return -1;
int sum0=pref[y][0]-(x==0?0:pref[x-1][0]);
int sum1=pref[y][1]-(x==0?0:pref[x-1][1]);
int sum2=pref[y][2]-(x==0?0:pref[x-1][2]);
int sum3=pref[y][3]-(x==0?0:pref[x-1][3]);
int sum4=pref[y][4]-(x==0?0:pref[x-1][4]);
int sum5=pref[y][5]-(x==0?0:pref[x-1][5]);
return max(sum0,sum3)+max(sum1,sum4)+max(sum2,sum5)-max({abs(sum0-sum3),abs(sum1-sum4),abs(sum2-sum5)});
}
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... |