129122025-01-03 12:00:16PKBDNS szakaszok száma (75 pont)cpp17Time limit exceeded 0/75300ms932 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int dns_length;
    cin >> dns_length;

    string dns;
    cin >> dns;

    int found_dns = 0;

    // Count occurrences of 'T' after each position
    vector<int> count_T(dns_length + 1, 0);  // count_T[i] stores the number of 'T's from index i to the end
    for (int i = dns_length - 1; i >= 0; i--) {
        count_T[i] = count_T[i + 1] + (dns[i] == 'T');
    }

    // Now count 'A' and 'G' pairs
    for (int i = 0; i < dns_length - 2; i++) {
        if (dns[i] == 'A') {
            for (int j = i + 1; j < dns_length - 1; j++) {
                if (dns[j] == 'G') {
                    // For every 'A' and 'G' pair, add the number of 'T's after position j
                    found_dns += count_T[j + 1];
                }
            }
        }
    }

    cout << found_dns-1 << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Accepted0/01ms320 KiB
2Time limit exceeded0/0272ms824 KiB
3Wrong answer0/31ms320 KiB
4Wrong answer0/41ms320 KiB
5Wrong answer0/41ms500 KiB
6Wrong answer0/41ms320 KiB
7Wrong answer0/41ms320 KiB
8Wrong answer0/31ms340 KiB
9Wrong answer0/31ms508 KiB
10Wrong answer0/41ms320 KiB
11Wrong answer0/41ms320 KiB
12Wrong answer0/41ms320 KiB
13Wrong answer0/41ms412 KiB
14Wrong answer0/41ms320 KiB
15Time limit exceeded0/3300ms824 KiB
16Time limit exceeded0/4300ms824 KiB
17Time limit exceeded0/4300ms824 KiB
18Time limit exceeded0/4282ms824 KiB
19Time limit exceeded0/4280ms824 KiB
20Time limit exceeded0/4280ms932 KiB
21Time limit exceeded0/3300ms824 KiB
22Time limit exceeded0/4282ms824 KiB