제출 #625287

#제출 시각아이디문제언어결과실행 시간메모리
625287moyindavidDNA 돌연변이 (IOI21_dna)C++17
0 / 100
38 ms5900 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; const int n=100000; int AT[n]{0},TA[n]{0},AC[n]{0},CA[n]{0},TC[n]{0},CT[n]{0}; void init(string a, string b) { for(int i=0;i<n;i++){ if(i!=0){ AT[i]=AT[i-1];TA[i]=TA[i-1];AC[i]=AC[i-1];CA[i]=CA[i-1];TC[i]=TC[i-1];CT[i]=CT[i-1]; } if(a[i]=='A'&&b[i]=='T')AT[i]++; else if(a[i]=='T'&&b[i]=='A')TA[i]++; else if(a[i]=='A'&&b[i]=='C')AC[i]++; else if(a[i]=='C'&&b[i]=='A')CA[i]++; else if(a[i]=='T'&&b[i]=='C')TC[i]++; else if(a[i]=='C'&&b[i]=='T')CT[i]++; } } int get_distance(int x, int y) { int ans=0; x=max(x-1,0); ans+=min(TA[y]-TA[x],AT[y]-AT[x])+min(AC[y]-AC[x],CA[y]-CA[x])+min(TC[y]-TC[x],CT[y]-CT[x]); int rem=abs(TA[y]-TA[x]-(AT[y]-AT[x]))+abs(AC[y]-AC[x]-(CA[y]-CA[x]))+abs(TC[y]-TC[x]-(CT[y]-CT[x])); if(rem%3!=0)return -1; ans+=rem/3*2; 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...