제출 #1018323

#제출 시각아이디문제언어결과실행 시간메모리
1018323andrewpDNA 돌연변이 (IOI21_dna)C++17
0 / 100
41 ms6992 KiB
#include "dna.h" #include "bits/stdc++.h" using namespace std; int ps[(int)(1e5+1)][3][2], pr[(int)(1e5+1)][6]; void init(std::string a, std::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]-pr[x-1][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; }
#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...