Submission #437154

# Submission time Handle Problem Language Result Execution time Memory
437154 2021-06-25T23:48:59 Z ScarletS Mutating DNA (IOI21_dna) C++17
Compilation error
0 ms 0 KB
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5+7;
int p[6][N], r[6];

void init(std::string a, std::string b) {
	int n = a.size();
	for (int i=0;i<n;++i)
	{
		for (int j=0;j<6;++j)
			p[j][i+1] = p[j][i];
		if (s[i] == 'A')
		{
			if (t[i] == 'T')
				++p[0][i+1];
			if (t[i] == 'C')
				++p[1][i+1];
		}
		if (s[i] == 'T')
		{
			if (t[i] == 'A')
				++p[2][i+1];
			if (t[i] == 'C')
				++p[3][i+1];
		}
		if (s[i] == 'C')
		{
			if (t[i] == 'A')
				++p[4][i+1];
			if (t[i] == 'T')
				++p[5][i+1];
		}
	}
}

int pair_up(int x, int y)
{
	int z = min(r[x], r[y]);
	r[x] -= z;
	r[y] -= z;
	return z;
}

int get_distance(int x, int y)
{
	int ans = 0;
	++x;
	++y;
	for (int i=0;i<6;++i)
		r[i] = p[i][y] - p[i][x-1];
	if (r[0] + r[1] != r[2] + r[4] || r[2] + r[3] != r[0] + r[5] || r[4] + r[5] != r[1] + r[3])
		return -1;
	ans += pair_up(0, 2);
	ans += pair_up(1, 4);
	ans += pair_up(3, 5);
	return ans + ((r[0] + r[1] + r[2] + r[3] + r[4] + r[5])/3)*2;
}

Compilation message

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:14:7: error: 's' was not declared in this scope
   14 |   if (s[i] == 'A')
      |       ^
dna.cpp:16:8: error: 't' was not declared in this scope
   16 |    if (t[i] == 'T')
      |        ^
dna.cpp:18:8: error: 't' was not declared in this scope
   18 |    if (t[i] == 'C')
      |        ^
dna.cpp:21:7: error: 's' was not declared in this scope
   21 |   if (s[i] == 'T')
      |       ^
dna.cpp:23:8: error: 't' was not declared in this scope
   23 |    if (t[i] == 'A')
      |        ^
dna.cpp:25:8: error: 't' was not declared in this scope
   25 |    if (t[i] == 'C')
      |        ^
dna.cpp:28:7: error: 's' was not declared in this scope
   28 |   if (s[i] == 'C')
      |       ^
dna.cpp:30:8: error: 't' was not declared in this scope
   30 |    if (t[i] == 'A')
      |        ^
dna.cpp:32:8: error: 't' was not declared in this scope
   32 |    if (t[i] == 'T')
      |        ^