179432025-09-23 19:38:32algoproDNS szakaszok száma (75 pont)pypy3Wrong answer 3/7571ms32000 KiB
# UUID: 5959ce2d-dea8-4c0c-b91b-27a158dfdd68

"""
hossz = int(input())
dns = str(input())
van = False
eset = 0
for i in range(hossz):
    if dns[i] == "A":
        van = False
        for j in range(i, hossz):
            if dns[j] == "G":
                van = True
            if dns[j] == "T" and van:
                eset += 1
print(eset)



hossz = int(input())
dns = str(input())
eset = 0
for i in range(hossz):
    if dns[i] == "A":
        g = 0
        for j in range(i, hossz):
            if dns[j] == "G":
                g = 1
            if dns[j] == "T" and g == 1:
                eset += 1
print(eset)
erre a peldara:
CAGTAATTGATA
hany A betu van egy adott karakter elott?
011123333445 <- ez lesz az A lista
Es melyik az elottt levo G indexe
CAGTAATTGATA
xx2222228888 <- az elott levo G betu indexe, ha x=-1, akkor ez egy listaban tarolhato
es ezek utan amikor vegigmegyunk 3-adszorra a stringen:
CAGTAATTGATA
   T <- egy T betu
   3-as indexu helyen
   G[3] megmondja, hogy hol van elotte eloszor G betu
   A[G[3]] megmondja, hogy hany A betu van elotte
      T 6-os indexen
      A[G[6]]-tal novelni kell a valaszt
      stb

"""


hossz = int(input())
dns = input().strip()
if hossz != len(dns):
    while True:
        x=0
A = []
a = 0
for i in range(hossz):
    #if dns[i] == "A":
    #    a += 1
    A.append(a)
#print(A)#eddig jonak tunik

G = []
g = -1
for i in range(hossz):
    if dns[i] == "G":
        g = i
    G.append(g)
#print(G)
megoldas = 0
for i in range(hossz):
    if dns[i] == "T":
        if G[i] != -1: # a -1 azt jelenti, hogy nincs elotte G azaz jo
            megoldas += A[G[i]]
        #print(i, G[i], A[i], A[G[i]])
print(megoldas)
SubtaskSumTestVerdictTimeMemory
base3/75
1Wrong answer0/043ms19384 KiB
2Runtime error0/070ms32000 KiB
3Accepted3/339ms19428 KiB
4Wrong answer0/439ms19424 KiB
5Wrong answer0/439ms19500 KiB
6Wrong answer0/443ms19324 KiB
7Wrong answer0/439ms19528 KiB
8Wrong answer0/339ms19432 KiB
9Wrong answer0/343ms19532 KiB
10Wrong answer0/445ms19608 KiB
11Wrong answer0/439ms19692 KiB
12Wrong answer0/441ms19876 KiB
13Wrong answer0/439ms19824 KiB
14Wrong answer0/445ms19696 KiB
15Runtime error0/367ms32000 KiB
16Runtime error0/459ms32000 KiB
17Runtime error0/470ms32000 KiB
18Runtime error0/468ms32000 KiB
19Runtime error0/457ms32000 KiB
20Runtime error0/471ms32000 KiB
21Runtime error0/364ms32000 KiB
22Runtime error0/461ms32000 KiB