Submission #1018312

#TimeUsernameProblemLanguageResultExecution timeMemory
1018312andrewpMutating DNA (IOI21_dna)C++17
0 / 100
29 ms11996 KiB
#include "dna.h" #include "bits/stdc++.h" using namespace std; const int mxN=2e5+1; int ps[mxN][3][2], pr[mxN][6]; void init(string a, string b) { int n=a.size(); a='i'+a, b='i'+b; for(int i=1; i<=n; ++i) { ps[i][0][0]=ps[i-1][0][0]; ps[i][1][0]=ps[i-1][1][0]; ps[i][2][0]=ps[i-1][2][0]; ps[i][0][1]=ps[i-1][0][1]; ps[i][1][1]=ps[i-1][1][1]; ps[i][2][1]=ps[i-1][2][1]; if(a[i]=='A') ++ps[i][0][0]; else if(a[i]=='C') ++ps[i][1][0]; else ++ps[i][2][0]; if(b[i]=='A') ++ps[i][0][1]; else if(b[i]=='C') ++ps[i][1][1]; else ++ps[i][2][1]; for(int j=0; j<6; ++j) pr[i][j]=pr[i-1][j]; if(a[i]=='A'&&b[i]=='C') ++pr[i][0]; if(a[i]=='C'&&b[i]=='A') ++pr[i][1]; if(a[i]=='A'&&b[i]=='T') ++pr[i][2]; if(a[i]=='T'&&b[i]=='A') ++pr[i][3]; if(a[i]=='C'&&b[i]=='T') ++pr[i][4]; if(a[i]=='T'&&b[i]=='C') ++pr[i][5]; } } int get_distance(int x, int y) { ++x, ++y; for(int i=0; i<3; ++i) { if((ps[y][i][0]-ps[x-1][i][0])!=(ps[y][i][1]-ps[x-1][i][1])) { return -1; } } vector<int> v; for(int i=0; i<6; ++i) v.push_back(pr[y+1][i]-pr[x][0]); int p=min(v[0], v[1]), q=min(v[2], v[3]), r=min(v[4], v[5]); v[0]-=p, v[1]-=p; int ans=p+q+r; ans+=2*max(v[0], v[1]); return ans; } //int main() { // int n; // cin >> n; // string a, b; // cin >> a >> b; // init(a, b); // cout << get_distance(2, 4) << "\n"; // //}
#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...