제출 #1130273

#제출 시각아이디문제언어결과실행 시간메모리
1130273Ak_16DNA 돌연변이 (IOI21_dna)C++20
100 / 100
31 ms6152 KiB
#include <iostream> #include <string> using namespace std; int paa[100005]; int pac[100005]; int pat[100005]; int pca[100005]; int pcc[100005]; int pct[100005]; int pta[100005]; int ptc[100005]; int ptt[100005]; void init(string a, string b){ int n = a.size(); paa[0]=0; pac[0]=0; pat[0]=0; pca[0]=0; pcc[0]=0; pct[0]=0; pta[0]=0; ptc[0]=0; ptt[0]=0; for(int i=1; i<=n; i++){ paa[i] = paa[i-1]; pac[i] = pac[i-1]; pat[i] = pat[i-1]; pca[i] = pca[i-1]; pcc[i] = pcc[i-1]; pct[i] = pct[i-1]; pta[i] = pta[i-1]; ptc[i] = ptc[i-1]; ptt[i] = ptt[i-1]; if(a[i-1]=='A'&&b[i-1]=='A'){paa[i]++;} if(a[i-1]=='A'&&b[i-1]=='C'){pac[i]++;} if(a[i-1]=='A'&&b[i-1]=='T'){pat[i]++;} if(a[i-1]=='C'&&b[i-1]=='A'){pca[i]++;} if(a[i-1]=='C'&&b[i-1]=='C'){pcc[i]++;} if(a[i-1]=='C'&&b[i-1]=='T'){pct[i]++;} if(a[i-1]=='T'&&b[i-1]=='A'){pta[i]++;} if(a[i-1]=='T'&&b[i-1]=='C'){ptc[i]++;} if(a[i-1]=='T'&&b[i-1]=='T'){ptt[i]++;} } } int get_distance(int x, int y){ x++; y++; int n1 = paa[y] - paa[x-1]; int n2 = pac[y] - pac[x-1]; int n3 = pat[y] - pat[x-1]; int n4 = pca[y] - pca[x-1]; int n5 = pcc[y] - pcc[x-1]; int n6 = pct[y] - pct[x-1]; int n7 = pta[y] - pta[x-1]; int n8 = ptc[y] - ptc[x-1]; int n9 = ptt[y] - ptt[x-1]; if(n2+n3!=n4+n7){return -1;} if(n4+n6!=n2+n8){return -1;} if(n7+n8!=n3+n6){return -1;} int ans = 0; n1 = 0; n5 = 0; n9 = 0; int m1 = min(n2, n4); int m2 = min(n3, n7); int m3 = min(n6, n8); ans += m1 + m2 + m3; n2 -= m1; n4 -= m1; n3 -= m2; n7 -= m2; n6 -= m3; n8 -= m3; ans += ( (n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9) * 2 / 3) ; 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...