Submission #529229

#TimeUsernameProblemLanguageResultExecution timeMemory
529229Icebear16Mutating DNA (IOI21_dna)C++17
35 / 100
34 ms4936 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; void init(std::string a, std::string b) { n=a.length(); s=a,c=b; A.push_back(0),B.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); }else{ B.push_back(0); } }else{ A.push_back(0); B.push_back(0); } } for(int i=1;i<=n;i++){ A[i]+=A[i-1]; B[i]+=B[i-1]; } while(q--){ int x,y; get_distance(x,y); } } int get_distance(int x, int y) { // int h1=0,h2=0,l1=0,l2=0,k1=0,k2=0; // for(int i=x;i<=y;i++){ // if(s[i]=='A'){ // h1++; // }else if(s[i]=='T'){ // l1++; // }else if(s[i]=='C'){ // k1++; // } // if(c[i]=='A'){ // h2++; // }else if(c[i]=='T'){ // l2++; // }else if(c[i]=='C'){ // k2++; // } // } int j=A[y+1]-A[x],k=B[y+1]-B[x]; if(j%2==0 && k*2==j){ return k; }else{ return -1; } } //7 3 //ATATATA //TATTATT //1 5 //0 2 //0 6 //-1 //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...