Submission #499608

#TimeUsernameProblemLanguageResultExecution timeMemory
499608ETKMutating DNA (IOI21_dna)C++17
100 / 100
59 ms7296 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; int S[100005][3][3],n; int id(char c){ if(c=='A')return 0; if(c=='T')return 1; return 2; } void init(string a,string b){ n = a.size(); for(int i=1;i<=n;i++){ for(int j=0;j<3;j++)for(int k=0;k<3;k++) S[i][j][k] = S[i-1][j][k]; S[i][id(a[i-1])][id(b[i-1])]++; } } int get_distance(int x,int y){ vector <vector<int>> sum(3,vector<int>(3)); for(int i=0;i<3;i++)for(int j=0;j<3;j++) sum[i][j] = S[y+1][i][j] - S[x][i][j]; int ans = 0; for(int i=0;i<3;i++)for(int j=i+1;j<3;j++){ int d = min(sum[i][j],sum[j][i]); ans += d, sum[i][j] -= d, sum[j][i] -= d; } if(!(sum[0][1]==sum[1][2]&&sum[1][2]==sum[2][0]))return -1; if(!(sum[1][0]==sum[2][1]&&sum[2][1]==sum[0][2]))return -1; ans += 2*(sum[0][1]+sum[1][0]); 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...