CSES - Datatähti 2024 alku - Results
Submission details
Task:Laskettelukeskus
Sender:Ojar23
Submission time:2023-11-08 12:54:00 +0200
Language:Python3 (CPython3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#1ACCEPTED0.02 s1, 2details
#20.03 s1, 2details
#30.04 s1, 2details
#4--2details
#5--2details
#60.02 s1, 2details
#70.35 s2details
#8ACCEPTED0.13 s1, 2details
#9--2details
#10--1, 2details
#11--2details
#12--1, 2details
#13--2details

Code

import time
def canGo(a,b, paths):
    for x in paths:
        if a in x and b in x:
            return True
    return False

def findWay(target, paths):
    current = 1
    fol = 2
    way = [1]
    nots = []
    i = 0
    while current != target:
        through = True
        for x in paths:
            #print(f"{x[0]} == {current} and {x[1]} == {fol}")
            if(x[0] == str(current) and x[1] == str(fol) and fol not in nots and fol not in way):
                way.append(fol)
                current = fol
                fol += 1
                #print(way)
                through = False
                break
        if(through):
            #print("helo")
            fol += 1
            if(fol > target):
                nots.append(way[len(way)-1])
                way.pop()
                #print(f"Nots: {nots}")
                current = way[len(way)-1]
                fol = current+1
        i += 1
        #time.sleep(1)
    return way

linesA = int(input())
slopes = {}
paths = []
for i in range(linesA-1):
    paths.append(input().split(" "))
times = input().split(" ")
for i in range(1,linesA+1):
    slopes.update({i:int(times[i-1])})
a = 0
b = 0
sValues = list(slopes.values())
aurat = 0
while sValues.count(0) != len(sValues):
    a = 0
    b = 0
    sValues = list(slopes.values())
    while sValues.count(0) != len(sValues):
        i = 0
        for x in sValues[::-1]:
            if x != 0:
                paikka = len(sValues)-i
                rinne = paikka
                #print(f"Rinne {rinne}, paikka: {paikka}")
                break
            i += 1
        break
        a += 1
    way = findWay(rinne, paths)
    for x in  way:
        if slopes.get(int(x)) != 0:
            slopes.update({int(x):slopes.get(int(x))-1})
        else:
            slopes.update({int(x):0})
    aurat += 1
aurat = aurat -1
print(aurat)

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
5
1 2
1 3
3 4
3 5
...

correct output
6

user output
6

Test 2

Group: 1, 2

Verdict:

input
100
1 73
1 64
64 23
1 88
...

correct output
2675

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 65, in <module>
    w...

Test 3

Group: 1, 2

Verdict:

input
100
1 36
36 56
56 59
36 97
...

correct output
2808

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 65, in <module>
    w...

Test 4

Group: 2

Verdict:

input
100000
1 45452
1 74209
45452 78960
45452 79820
...

correct output
28399367694319

user output
(empty)

Test 5

Group: 2

Verdict:

input
100000
1 31165
1 23263
31165 89516
31165 53122
...

correct output
28546840313799

user output
(empty)

Test 6

Group: 1, 2

Verdict:

input
100
1 79
79 9
79 45
45 10
...

correct output
0

user output
-1

Test 7

Group: 2

Verdict:

input
100000
1 66038
1 56789
56789 7403
66038 69542
...

correct output
0

user output
-1

Test 8

Group: 1, 2

Verdict: ACCEPTED

input
100
1 2
2 3
3 4
4 5
...

correct output
100

user output
100

Test 9

Group: 2

Verdict:

input
100000
1 2
2 3
3 4
4 5
...

correct output
1000000000

user output
(empty)

Test 10

Group: 1, 2

Verdict:

input
100
1 2
1 3
2 4
2 5
...

correct output
2809

user output
(empty)

Test 11

Group: 2

Verdict:

input
100000
1 2
1 3
2 4
2 5
...

correct output
26053917212428

user output
(empty)

Test 12

Group: 1, 2

Verdict:

input
100
1 2
1 3
2 4
2 5
...

correct output
5000

user output
(empty)

Test 13

Group: 2

Verdict:

input
100000
1 2
1 3
2 4
2 5
...

correct output
50000000000000

user output
(empty)