제출 #529288

#제출 시각아이디문제언어결과실행 시간메모리
529288Icebear16DNA 돌연변이 (IOI21_dna)C++17
21 / 100
37 ms5500 KiB
#include "dna.h" #include<vector> int n,q; std::string s; std::string c; std::vector<int> A; std::vector<int> B; std::vector<int> C; std::vector<int> D; std::vector<int> E; std::vector<int> F; std::vector<int> G; void init(std::string a, std::string b) { n=a.length(); s=a,c=b; A.push_back(0),B.push_back(0),C.push_back(0),D.push_back(0),E.push_back(0),F.push_back(0),G.push_back(0); for(int i=0;i<n;i++){ if(a[i]!=b[i]){ A.push_back(1); if(s[i]=='A'){ B.push_back(1); C.push_back(0); F.push_back(0); }else if(s[i]=='C'){ C.push_back(1); B.push_back(0); F.push_back(0); }else{ F.push_back(1); B.push_back(0); C.push_back(0); } if(c[i]=='A'){ D.push_back(1); E.push_back(0); G.push_back(0); }else if(c[i]=='C'){ E.push_back(1); D.push_back(0); G.push_back(0); }else{ G.push_back(1); D.push_back(0); E.push_back(0); } }else{ A.push_back(0); B.push_back(0); C.push_back(0); D.push_back(0); E.push_back(0); F.push_back(0); G.push_back(0); } } for(int i=1;i<=n;i++){ A[i]+=A[i-1]; B[i]+=B[i-1]; C[i]+=C[i-1]; D[i]+=D[i-1]; E[i]+=E[i-1]; F[i]+=F[i-1]; G[i]+=G[i-1]; } while(q--){ int x,y; get_distance(x,y); } } int get_distance(int x, int y) { int j=A[y+1]-A[x],h1=B[y+1]-B[x],h2=D[y+1]-D[x],l1=C[y+1]-C[x],l2=E[y+1]-E[x],k1=F[y+1]-F[x],k2=G[y+1]-G[x]; if((h1+l1+k1)==j && h1==h2 && l1==l2 && k1==k2){ if(j%3==1){ return j/2; }else if(j%3==2){ return (j/3)+1; }else{ return 2*(j/3); } return j/2; }else{ return -1; } } //7 3 //ATATATA //TATTATT //1 5 //0 2 //0 6 //-1 //0 //-1 //3 2 //ATC //CAT //0 2 //0 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...