130892025-01-06 14:08:40lacitoDNS szakaszok száma (75 pont)cpp17Accepted 75/754ms1460 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/01ms316 KiB
2Accepted0/04ms1312 KiB
3Accepted3/31ms508 KiB
4Accepted4/41ms316 KiB
5Accepted4/41ms316 KiB
6Accepted4/41ms316 KiB
7Accepted4/41ms316 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms556 KiB
10Accepted4/41ms316 KiB
11Accepted4/41ms316 KiB
12Accepted4/41ms316 KiB
13Accepted4/41ms524 KiB
14Accepted4/41ms508 KiB
15Accepted3/34ms1344 KiB
16Accepted4/44ms1332 KiB
17Accepted4/44ms1312 KiB
18Accepted4/44ms1332 KiB
19Accepted4/44ms1332 KiB
20Accepted4/44ms1460 KiB
21Accepted3/34ms1444 KiB
22Accepted4/44ms1376 KiB