Submission #689475

#TimeUsernameProblemLanguageResultExecution timeMemory
689475coding_snorlaxMutating DNA (IOI21_dna)C++17
100 / 100
36 ms5548 KiB
#include<bits/stdc++.h> #include "dna.h" using namespace std; #define pb push_back vector<int> A_T={0},T_A={0},A_C={0},C_A={0},C_T={0},T_C={0}; void init(string a, string b){ for(int i=0;i<(int)a.size();i++){ A_T.pb(A_T.back());T_A.pb(T_A.back());A_C.pb(A_C.back());C_A.pb(C_A.back());C_T.pb(C_T.back());T_C.pb(T_C.back()); if(a[i]=='A' && b[i]=='T'){ A_T.back() = A_T.back()+1; } else if(a[i]=='T' && b[i]=='A'){ T_A.back() = T_A.back()+1; } else if(a[i]=='A' && b[i]=='C'){ A_C.back() = A_C.back()+1; } else if(a[i]=='C' && b[i]=='A'){ C_A.back() = C_A.back()+1; } else if(a[i]=='C' && b[i]=='T'){ C_T.back() = C_T.back()+1; } else if(a[i]=='T' && b[i]=='C'){ T_C.back() = T_C.back()+1; } } } int get_distance(int x,int y){ int a = A_T[y+1]-A_T[x] , b = T_A[y+1]-T_A[x] , c = A_C[y+1]-A_C[x], d= C_A[y+1]-C_A[x],e = C_T[y+1]-C_T[x],f=T_C[y+1]-T_C[x]; if(a+c != b+d || b+f != a+e || d+e != c+f) return -1; else{ int Count = min(a,b)+min(c,d)+min(e,f); return Count + (a+b+c+d+e+f-2*Count)*2 /3; } }
#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...