179392025-09-23 19:34:32algoproDNS szakaszok száma (75 pont)pypy3Wrong answer 3/7570ms32000 KiB
# UUID: 54eadf32-873b-4a57-a7ce-e093bec8147f

"""
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()
hossz = len(dns)
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/039ms19604 KiB
2Runtime error0/059ms32000 KiB
3Accepted3/343ms19276 KiB
4Wrong answer0/445ms19268 KiB
5Wrong answer0/445ms19356 KiB
6Wrong answer0/439ms19488 KiB
7Wrong answer0/445ms19420 KiB
8Wrong answer0/339ms19324 KiB
9Wrong answer0/339ms19456 KiB
10Wrong answer0/443ms19540 KiB
11Wrong answer0/437ms19692 KiB
12Wrong answer0/445ms19716 KiB
13Wrong answer0/445ms19628 KiB
14Wrong answer0/443ms19768 KiB
15Runtime error0/359ms32000 KiB
16Runtime error0/457ms32000 KiB
17Runtime error0/470ms32000 KiB
18Runtime error0/468ms32000 KiB
19Runtime error0/467ms32000 KiB
20Runtime error0/459ms32000 KiB
21Runtime error0/370ms32000 KiB
22Runtime error0/468ms32000 KiB