83962024-01-15 15:32:31tomi7DNS szakaszok száma (75 pont)cpp17Wrong answer 68/758ms7212 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());
	int 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
base68/75
1Accepted0/03ms1828 KiB
2Accepted0/08ms5004 KiB
3Accepted3/33ms2360 KiB
4Accepted4/43ms2444 KiB
5Accepted4/42ms2424 KiB
6Accepted4/43ms2708 KiB
7Accepted4/43ms2836 KiB
8Accepted3/33ms2840 KiB
9Accepted3/33ms2836 KiB
10Accepted4/43ms3040 KiB
11Accepted4/43ms3092 KiB
12Accepted4/43ms3020 KiB
13Accepted4/43ms3228 KiB
14Accepted4/43ms3436 KiB
15Accepted3/38ms6244 KiB
16Accepted4/48ms6712 KiB
17Accepted4/48ms6900 KiB
18Accepted4/48ms6912 KiB
19Accepted4/47ms6944 KiB
20Accepted4/48ms7212 KiB
21Wrong answer0/37ms7168 KiB
22Wrong answer0/47ms7144 KiB