7212021-12-21 10:58:16kidesoDNScpp11Runtime error 8/4035ms59036 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][j - 1];
			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
base8/40
1Accepted0/02ms1748 KiB
2Runtime error0/032ms49572 KiB
3Accepted2/21ms2028 KiB
4Accepted2/21ms2088 KiB
5Accepted2/21ms2368 KiB
6Wrong answer0/27ms11728 KiB
7Accepted2/225ms40972 KiB
8Runtime error0/428ms59036 KiB
9Runtime error0/427ms55716 KiB
10Runtime error0/430ms53324 KiB
11Runtime error0/428ms53588 KiB
12Runtime error0/432ms50068 KiB
13Runtime error0/529ms52432 KiB
14Runtime error0/535ms50308 KiB