Rezultati

Up. imeNalogaJezikRezultatČas oddaje
narcos Prijateljske besede Python 3 100/100OK 20. apr '17 @ 20:16

Test Točke Porabljen spomin Porabljen čas Status
#1 12/12 8,797 MiB 0,000 s OK
#2 12/12 8,824 MiB 0,000 s OK
#3 12/12 9,613 MiB 4,433 s OK
#4 12/12 9,582 MiB 4,139 s OK
#5 13/13 9,313 MiB 0,000 s OK
#6 13/13 9,285 MiB 1,850 s OK
#7 13/13 9,352 MiB 0,000 s OK
#8 13/13 9,324 MiB 3,352 s OK

Ocenjevani program (tiest.py):
import sys
from collections import Counter
f= sys.stdin
#f = open('test.txt','r')
lines = f.read().strip().split('\n')
lines = lines[1:]
counts = Counter(lines)
friends = set()
friends.add(lines[0])
m = set()
m.add(lines[0])
lines = set(lines)
tr = set()        
while m != set():
    m = friends - tr
    for y in m:
        for z in lines:
            if (z[:3]==y[:3] or y[-3:]==z[-3:]) and z!=y:
                friends.add(z)
        lines.remove(y)
    tr = tr | m   
       
total = 0

for x in friends:
    total += counts[x]

   
print(total)    
f.close()