7202021-12-21 10:54:44kidesoDNScpp11Runtime error 0/4063ms59136 KiB
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct adat { bool jo = false; int A, C, G, T; };
vector <vector <adat> > x;
int N, m = 1;
bool o;
string s;

void cs(int i, int j, char c)
{
	o = false;
	if (c == 'A')
	{
		++x[i][j].A;
		if (x[i][j].A * 2 >= j - i + 1) o = true;
	}
	else if (c == 'C')
	{
		++x[i][j].C;
		if (x[i][j].C * 2 >= j - i + 1) o = true;
	}
	else if (c == 'G')
	{
		++x[i][j].G;
		if (x[i][j].G * 2 >= j - i + 1) o = true;
	}
	else if (c == 'T')
	{
		++x[i][j].T;
		if (x[i][j].T * 2 >= j - i + 1) o = true;
	}
}

int main()
{
	cin >> s;
	N = s.length();

	x.resize(N + 1, vector<adat>(N + 1));

	for (int i = 1; i <= N; ++i)
	{
		x[i][i].jo = true;
		cs(i, i, s[i - 1]);
	}

	for (int i = 1; i <= N; ++i)
	{
		for (int j = i + 1; j <= N; ++j)
		{
			x[i][j] = x[i - 1][j];
			x[i][j].jo = false;
			cs(i, j, s[j - 1]);
			x[i][j].jo = o;
			if (x[i][j].jo) m = max(m, j - i + 1);
		}
	}

	cout << m;

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Accepted0/03ms1928 KiB
2Runtime error0/046ms49732 KiB
3Wrong answer0/22ms2188 KiB
4Wrong answer0/22ms2248 KiB
5Wrong answer0/22ms2528 KiB
6Wrong answer0/210ms11892 KiB
7Wrong answer0/228ms41132 KiB
8Runtime error0/452ms59136 KiB
9Runtime error0/463ms55848 KiB
10Runtime error0/437ms53328 KiB
11Runtime error0/430ms53704 KiB
12Runtime error0/428ms50232 KiB
13Runtime error0/532ms52452 KiB
14Runtime error0/529ms50424 KiB