Submission #483677

#TimeUsernameProblemLanguageResultExecution timeMemory
483677StrawHatWessMutating DNA (IOI21_dna)C++17
0 / 100
35 ms6372 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int>vi; typedef string str; #define pb push_back #define sz(v) (int)v.size() #define FOR(i,a,b) for(int i=a; i<b; i++) //------------------------------------------------- const int MX=1e5+10; int p[3][3][MX]; void init(str a, str b){ map<char,int>mp; mp['A']=0; mp['C']=1; mp['T']=2; memset(p,0,sizeof(p)); int N=sz(a); FOR(i,0,N){ p[mp[a[i]]][mp[b[i]]][i]=1; } FOR(x,0,3) FOR(y,0,3) FOR(i,1,N) p[x][y][i]+=p[x][y][i-1]; } int get_distance(int l, int r) { int n=0,ans=0; FOR(x,0,3) FOR(y,x+1,3){ int v1=p[x][y][r]; if(l) v1-=p[x][y][l-1]; int v2=p[y][x][r]; if(l) v2-=p[y][x][l-1]; ans+=min(v1,v2); n+=max(v1,v2)-min(v1,v2); } if(n%3) return -1; ans+=(n/3)*2; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...