# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092153 | user736482 | Mutating DNA (IOI21_dna) | C++17 | 0 ms | 0 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 <bits/stdc++.h>using namespace std;long long a,b;vector<int>pref[6]; // A/T, T/C, C/A, T/A, C/T, A/Cvoid init(string a,string b){ for(int i=0;i<6;i++) pref[i].push_back(0); for(int i=0;i<a.size();i++){ for(int i=0;i<6;i++) pref[i].push_back(pref[i].back()); if(a[i]=='A' && b[i]=='T') pref[0].back()++; if(a[i]=='T' && b[i]=='C') pref[1].back()++; if(a[i]=='C' && b[i]=='A') pref[2].back()++; if(a[i]=='T' && b[i]=='A') pref[3].back()++; if(a[i]=='C' && b[i]=='T') pref[4].back()++; if(a[i]=='A' && b[i]=='C') pref[5].back()++; }}int get_distance(int x, int y){ x++; y++; int res=0; res+=min(pref[0][y]-pref[0][x-1],pref[3][y]-pref[3][x-1]); res+=min(pref[1][y]-pref[1][x-1],pref[4][y]-pref[4][x-1]); res+=min(pref[2][y]-pref[2][x-1],pref[5][y]-pref[5][x-1]); res+=2*abs(pref[1][y]-pref[1][x-1]-pref[4][y]+pref[4][x-1]); if(abs(pref[2][y]-pref[2][x-1]-pref[5][y]+pref[5][x-1])==abs(pref[1][y]-pref[1][x-1]-pref[4][y]+pref[4][x-1]) && abs(pref[2][y]-pref[2][x-1]-pref[5][y]+pref[5][x-1])==abs(pref[0][y]-pref[0][x-1]-pref[3][y]+pref[3][x-1])) return res; else return -1;}