Submission #689474

#TimeUsernameProblemLanguageResultExecution timeMemory
689474coding_snorlaxMutating DNA (IOI21_dna)C++17
100 / 100
35 ms5428 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++){ if(a[i]=='A' && b[i]=='T'){ A_T.pb(A_T.back()+1);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()); } else if(a[i]=='T' && b[i]=='A'){ A_T.pb(A_T.back());T_A.pb(T_A.back()+1);A_C.pb(A_C.back()); C_A.pb(C_A.back());C_T.pb(C_T.back());T_C.pb(T_C.back()); } else if(a[i]=='A' && b[i]=='C'){ A_T.pb(A_T.back());T_A.pb(T_A.back());A_C.pb(A_C.back()+1); C_A.pb(C_A.back());C_T.pb(C_T.back());T_C.pb(T_C.back()); } else if(a[i]=='C' && b[i]=='A'){ A_T.pb(A_T.back());T_A.pb(T_A.back());A_C.pb(A_C.back()); C_A.pb(C_A.back()+1);C_T.pb(C_T.back());T_C.pb(T_C.back()); } else if(a[i]=='C' && b[i]=='T'){ 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()+1);T_C.pb(T_C.back()); } else if(a[i]=='T' && b[i]=='C'){ 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()+1); } else{ 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()); } //cout<<" "<<A_T.size()<<" "<<i<<"\n"; } //cout<<A_T.size()<<" "; } 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]; //cout << a << " "<<b<<" "<< c<<" "<<d<<" "<<" "<<e<<" "<<f; 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...