84002024-01-15 15:36:30lacitoDNS szakaszok száma (75 pont)cpp17Accepted 75/756ms5996 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> tcount(n), nextg(n);
	int t = 0, g = -1;
	long long ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		tcount[i] = t;
		nextg[i] = g;
		if (s[i] == 'G') g = i;
		if (s[i] == 'T') t++;
		if (s[i] == 'A' && nextg[i] != -1) {
			ans += tcount[nextg[i]];
		}
	}
	cout << ans << endl;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1816 KiB
2Accepted0/06ms3880 KiB
3Accepted3/33ms2212 KiB
4Accepted4/43ms2300 KiB
5Accepted4/43ms2424 KiB
6Accepted4/43ms2636 KiB
7Accepted4/43ms2848 KiB
8Accepted3/33ms3060 KiB
9Accepted3/33ms3152 KiB
10Accepted4/43ms3296 KiB
11Accepted4/43ms3208 KiB
12Accepted4/43ms3188 KiB
13Accepted4/43ms3316 KiB
14Accepted4/43ms3428 KiB
15Accepted3/36ms5160 KiB
16Accepted4/46ms5136 KiB
17Accepted4/46ms5388 KiB
18Accepted4/46ms5476 KiB
19Accepted4/46ms5664 KiB
20Accepted4/46ms5880 KiB
21Accepted3/36ms5996 KiB
22Accepted4/46ms5980 KiB