# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1027662 | edogawa_something | Mutating DNA (IOI21_dna) | C++17 | 32 ms | 12324 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;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define pb push_back
#define all(v) v.begin(),v.end()
const ll M=2e5+10;
const ll inf=2e18;
ll pre[M][3][3];
void init(string a,string b){
for(int i=0;i<a.size();i++){
ll x,y;
if(a[i]=='C')
x=0;
if(a[i]=='T')
x=1;
if(a[i]=='A')
x=2;
if(b[i]=='C')
y=0;
if(b[i]=='T')
y=1;
if(b[i]=='A')
y=2;
pre[i+1][x][y]=1;
for(int j=0;j<3;j++){
for(int k=0;k<3;k++)
pre[i+1][j][k]+=pre[i][j][k];
}
}
}
int get_distance(int x, int y) {
ll cnt[3][3];
y++;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cnt[i][j]=pre[y][i][j]-pre[x][i][j];
for(int i=0;i<3;i++){
if(cnt[i][0]+cnt[i][1]+cnt[i][2]!=cnt[0][i]+cnt[1][i]+cnt[2][i])
return -1;
}
ll ans=0;
ll res=0;
for(int i=0;i<3;i++){
for(int j=i+1;j<3;j++){
ll x=min(cnt[i][j],cnt[j][i]);
res+=x;
cnt[i][j]-=x,cnt[j][i]-=x;
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++)
if(i!=j)
ans+=cnt[i][j];
}
return res+(ans*2)/3;
}
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... |