Submission #529250

#TimeUsernameProblemLanguageResultExecution timeMemory
529250Icebear16Mutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 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;
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);
	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)
			}else if(s[i]=='C'){
				C.push_back(1);
				B.push_back(0);
			}else{
				B.push_back(0);
				C.push_back(0);
			}
			if(c[i]=='A'){
				D.push_back(1);
				E.push_back(0)
			}else if(c[i]=='C'){
				D.push_back(1);
				E.push_back(0);
			}else{
				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);
		}
	}
	for(int i=1;i<=n;i++){
		A[i]+=A[i-1];
		B[i]+=B[i-1];
		C[i]+=A[i-1];
		D[i]+=B[i-1];
		E[i]+=A[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];
	if(h1==h2 && l1==l2){
		if(j%2==1){
			j+=1;
		}
		return j/2;
	}else{
		return -1;
	}
}
//7 3
//ATATATA
//TATTATT
//1 5
//0 2
//0 6
//-1
//0
//-1

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:20:19: error: expected ';' before '}' token
   20 |     C.push_back(0)
      |                   ^
      |                   ;
   21 |    }else if(s[i]=='C'){
      |    ~               
dna.cpp:30:19: error: expected ';' before '}' token
   30 |     E.push_back(0)
      |                   ^
      |                   ;
   31 |    }else if(c[i]=='C'){
      |    ~