83972024-01-15 15:32:51lacitoDNS szakaszok száma (75 pont)cpp17Wrong answer 0/757ms5128 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;
	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') ans += tcount[nextg[i]];
	}
	cout << ans << endl;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/03ms1812 KiB
2Wrong answer0/07ms4024 KiB
3Wrong answer0/33ms2228 KiB
4Wrong answer0/43ms2436 KiB
5Wrong answer0/42ms2448 KiB
6Wrong answer0/42ms2452 KiB
7Wrong answer0/42ms2456 KiB
8Wrong answer0/32ms2520 KiB
9Wrong answer0/33ms2560 KiB
10Wrong answer0/42ms2624 KiB
11Wrong answer0/43ms2640 KiB
12Wrong answer0/43ms2640 KiB
13Wrong answer0/43ms2760 KiB
14Wrong answer0/43ms2976 KiB
15Wrong answer0/36ms4808 KiB
16Wrong answer0/46ms4792 KiB
17Wrong answer0/46ms4788 KiB
18Wrong answer0/46ms4792 KiB
19Wrong answer0/46ms4828 KiB
20Wrong answer0/46ms5052 KiB
21Wrong answer0/36ms5000 KiB
22Wrong answer0/46ms5128 KiB