Submission #522934

#TimeUsernameProblemLanguageResultExecution timeMemory
522934TurkhuuMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h"
#include<bits/stdc++.h>

using namespace std;

vector<int> ax, at, ta, ct;

void init(std::string a, std::string b) {
	int n = (int)a.size();	
	ax.resize(n + 1);
	at.resize(n + 1);
	ta.resize(n + 1);
	ct.resize(n + 1);
	for(int i = 0; i < n; i++){
		ax[i + 1] = ax[i];
		at[i + 1] = at[i];
		ta[i + 1] = ta[i];
		ct[i + 1] = ct[i];
		if(a[i] == 'A' && b[i] != 'A'){
			ax[i + 1] += 1;
		}
		if(a[i] == 'A' && b[i] == 'T'){
			at[i + 1] += 1;
		}
		if(a[i] == 'T' && b[i] == 'A'){
			ta[i + 1] += 1;
		}
		if(a[i] == 'C' && b[i] == 'T'){
			ct[i + 1] += 1;
		}
		if(a[i] == 'T' && b[i] == 'C'){
			ct[i + 1] += 1;
		}
	}
}

int get_distance(int x, int y) {
	x += 1;
	y += 1;
	int AX = ax[x] - ax[y - 1];
	int AT = at[x] - at[y - 1];
	int TA = ta[x] - ta[y - 1];
	int CT = ct[x] - ct[y - 1;
	return AX + (CT + abs(AT - TA)) / 2;
}

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:43:27: error: expected ']' before ';' token
   43 |  int CT = ct[x] - ct[y - 1;
      |                           ^
      |                           ]