제출 #789037

#제출 시각아이디문제언어결과실행 시간메모리
789037Mouad_oujDNA 돌연변이 (IOI21_dna)C++17
0 / 100
36 ms6924 KiB
#include<bits/stdc++.h> //#include"prize.h" using namespace std; vector<int> ta,tc,ac,at,ca,ct; vector<int> pret1,prea1,prec1,pret2,prea2,prec2; //t a,c a t,c c a,t void init(string b, string a) { int n=a.size()+1; pret1.resize(n),prea1.resize(n),prec1.resize(n),pret2.resize(n),prea2.resize(n),prec2.resize(n); ta.resize(n),tc.resize(n),ac.resize(n),at.resize(n),ca.resize(n),ct.resize(n); pret1[0]=0,pret2[0]=0,prea1[0]=0,prea2[0]=0,prec1[0]=0,prec2[0]=0; ta[0]=0,tc[0]=0,ca[0]=0,ct[0]=0,ac[0]=0,at[0]=0; for(int x=1;x<n;x++) { pret1[x]=pret1[x-1],prea1[x]=prea1[x-1],prec1[x]=prec1[x-1]; if(a[x-1]=='T') pret1[x]++; if(a[x-1]=='C') prec1[x]++; if(a[x-1]=='A') prea1[x]++; pret2[x]=pret2[x-1],prea2[x]=prea2[x-1],prec2[x]=prec2[x-1]; if(b[x-1]=='T') pret2[x]++; if(b[x-1]=='C') prec2[x]++; if(b[x-1]=='A') prea2[x]++; ta[x]=ta[x-1],tc[x]=tc[x-1]; at[x]=at[x-1],ac[x]=ac[x-1]; ca[x]=ca[x-1],ct[x]=ct[x-1]; if(a[x-1]=='A' && b[x-1]=='C') ac[x]++; if(a[x-1]=='A' && b[x-1]=='T') at[x]++; if(a[x-1]=='T' && b[x-1]=='C') tc[x]++; if(a[x-1]=='T' && b[x-1]=='A') ta[x]++; if(a[x-1]=='C' && b[x-1]=='A') ca[x]++; if(a[x-1]=='C' && b[x-1]=='T') ct[x]++; } } int get_distance(int x, int y) { x++,y++; if(prea1[x]-prea1[y-1]==prea2[x]-prea2[y-1] && pret1[x]-pret1[y-1]==pret2[x]-pret2[y-1] && prec1[x]-prec1[y-1]==prec2[x]-prec2[y-1]) { int ans=0,cur=0; ans=min(ac[x]-ac[y-1],ca[x]-ca[y-1])+min(at[x]-at[y-1],ta[x]-ta[y-1])+min(ct[x]-ct[y-1],tc[x]-tc[y-1]); cur=max(ac[x]-ac[y-1],ca[x]-ca[y-1])+max(at[x]-at[y-1],ta[x]-ta[y-1])+max(ct[x]-ct[y-1],tc[x]-tc[y-1])-ans; ans+=(cur/3)*2; return ans; } else return -1; }
#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...