84022024-01-15 15:37:38tomi7DNS szakaszok száma (75 pont)cpp17Accepted 75/758ms6908 KiB
// Source: https://usaco.guide/general/io

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


int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> a;
	for(int i=0;i<n;i++){
		if(s[i]=='A'){
			a.push_back(1);
		}
		if(s[i]=='G'){
			a.push_back(2);
		}
		if(s[i]=='T'){
			a.push_back(3);
		}
	}
	vector<int> legkozelebbig;
	n=a.size();
	int elozog=0;
	for(int i=0;i<n;i++){
		if(a[i]==2){
			for(int j=elozog;j<i;j++){
				legkozelebbig.push_back(i);
			}
			elozog=i;
		}
	}
	for(int i=elozog;i<n;i++){
		legkozelebbig.push_back(-1);
	}
	vector<int> hanydarabtvan;
	int eddigi=0;
	reverse(a.begin(), a.end());
	for(int i=0;i<n;i++){
		if(a[i]==3){
			eddigi++;
		}
		hanydarabtvan.push_back(eddigi);
	}
	reverse(a.begin(), a.end());
	long long valasz=0;
	reverse(hanydarabtvan.begin(), hanydarabtvan.end());
	for(int i=0;i<n;i++){
		if(a[i]==1){
			valasz+=hanydarabtvan[legkozelebbig[i]];
		}
	}
	cout<<valasz<<'\n';
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1812 KiB
2Accepted0/08ms4996 KiB
3Accepted3/32ms2088 KiB
4Accepted4/43ms2328 KiB
5Accepted4/43ms2428 KiB
6Accepted4/42ms2508 KiB
7Accepted4/43ms2632 KiB
8Accepted3/33ms2844 KiB
9Accepted3/33ms3060 KiB
10Accepted4/42ms3140 KiB
11Accepted4/43ms3256 KiB
12Accepted4/42ms3240 KiB
13Accepted4/42ms3256 KiB
14Accepted4/43ms3156 KiB
15Accepted3/38ms5968 KiB
16Accepted4/48ms6176 KiB
17Accepted4/48ms6200 KiB
18Accepted4/48ms6332 KiB
19Accepted4/48ms6556 KiB
20Accepted4/47ms6584 KiB
21Accepted3/37ms6772 KiB
22Accepted4/47ms6908 KiB