206872026-01-08 17:39:34algoproDNScpp17Wrong answer 0/40317ms9924 KiB
// UUID: 63ab7caa-4b0d-4f97-9447-b4ab572cd77a
#include <bits/stdc++.h>
using namespace std;

int main() {
	string s; cin >> s;
	int n=s.size();
	int ans=0;
	for(char c : {'A', 'C', 'G', 'T'}){
		map<int, int> pos;
		pos[0]=-1;
		int runningTotal=0;
		for(int i=0;i<=n;i++){
			if(i<n) runningTotal+=(2*(c==s[i])-1);
			else{ runningTotal--; pos[runningTotal]++;}
			if(pos.count(runningTotal)==0) pos[runningTotal]=i;
			//printf("%d-%d (%c)\n", i, pos[pref[i+1]], c);
			ans=max(ans, i-pos[runningTotal]);
		}
	}
	cout << ans;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/01ms500 KiB
2Time limit exceeded0/0317ms6440 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/452ms1792 KiB
9Wrong answer0/497ms2756 KiB
10Wrong answer0/4122ms3136 KiB
11Wrong answer0/4173ms4292 KiB
12Wrong answer0/4180ms7460 KiB
13Wrong answer0/5224ms8900 KiB
14Wrong answer0/5256ms9924 KiB