Rezultati

Up. imeNalogaJezikRezultatČas oddaje
rokavcki-2018 Prehitevanje Python 3 100/100OK 04. okt '18 @ 18:51

Test Točke Porabljen spomin Porabljen čas Status
#1 16/16 8,668 MiB 0,000 s OK
#2 16/16 8,664 MiB 0,000 s OK
#3 17/17 8,516 MiB 0,000 s OK
#4 17/17 11,594 MiB 1,209 s OK
#5 17/17 67,910 MiB 3,955 s OK
#6 17/17 8,520 MiB 0,000 s OK

Ocenjevani program (prehitevanje.py):
n = int(input())

red = {}
m1 = input()
red["1"] = ['Error',m1]
red[m1] = ["1"]
for i in range(n-1):
    m2 = input()
    red[m1].append(m2)
    red[m2] = [m1]
    m1 = m2
red[m1].append("-1")
red["-1"] = [m1,'Error']

p = int(input())
for j in range(p):
    fast, slow = input().split(" ")

    # old position fix
    o1 = red[fast][0]
    o2 = red[fast][1]
    red[o1][1] = o2
    red[o2][0] = o1

    # new postion fix
    red[fast] = [red[slow][0], slow]
    #print(red[slow][0])
    red[red[slow][0]][1] = fast
    red[slow][0] = fast
#
# motoristi = red.keys()
# for motorist in motoristi:
#     if red[motorist][0] == "1":
#         x = motorist
#         break

x = red["1"][1]
#print(red)
while x != "-1":
    print(x)
    x = red[x][1]