502021-01-09 15:46:02mraronDNScpp11Elfogadva 40/4014ms8180 KiB
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	const char alpha[]={'A','G','C','T'};
	
	string s;
	cin>>s;
	int ans=0;
	for(auto c:alpha) {
		vector<int> arr(sz(s)+1);
		for(int i=1;i<=sz(s);++i) {
			arr[i]=2*(c==s[i-1])-1;
		}
		
		partial_sum(all(arr), arr.begin());
		vector<int> pos(2*sz(arr)+2,-1);
		for(int i=0;i<sz(arr);++i) {
			if(pos[arr[i]+sz(s)]>=0) {
				ans=max(ans, i-pos[arr[i]+sz(s)]);
			}else pos[arr[i]+sz(s)]=i;
		}
		
		if(arr.back()>=0) ans=sz(s);
	}
	cout<<ans<<"\n";
	
	return 0;
}


RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/02ms1752 KiB
2Elfogadva0/014ms7212 KiB
3Elfogadva2/21ms2048 KiB
4Elfogadva2/21ms2056 KiB
5Elfogadva2/21ms2064 KiB
6Elfogadva2/21ms2072 KiB
7Elfogadva2/21ms2076 KiB
8Elfogadva4/43ms3396 KiB
9Elfogadva4/44ms4408 KiB
10Elfogadva4/44ms5124 KiB
11Elfogadva4/46ms5912 KiB
12Elfogadva4/47ms6396 KiB
13Elfogadva5/58ms7452 KiB
14Elfogadva5/58ms8180 KiB