Submission details
Task:Microservice hell
Sender:aalto25f_002
Submission time:2025-10-08 17:48:02 +0300
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.06 sdetails
#20.06 sdetails
#30.06 sdetails
#40.07 sdetails
#50.07 sdetails
#60.06 sdetails
#70.07 sdetails
#80.07 sdetails
#90.07 sdetails
#100.06 sdetails
#110.06 sdetails
#120.07 sdetails
#130.06 sdetails
#140.06 sdetails
#150.07 sdetails
#160.06 sdetails
#170.07 sdetails
#180.06 sdetails
#190.07 sdetails
#200.06 sdetails
#210.07 sdetails
#220.06 sdetails
#230.06 sdetails
#240.06 sdetails
#250.06 sdetails
#260.06 sdetails
#270.06 sdetails
#280.06 sdetails
#290.06 sdetails
#300.06 sdetails
#310.06 sdetails
#320.06 sdetails
#330.06 sdetails
#340.06 sdetails
#350.06 sdetails
#360.06 sdetails
#370.07 sdetails
#380.06 sdetails
#390.06 sdetails
#400.06 sdetails
#410.06 sdetails
#420.06 sdetails
#430.06 sdetails
#440.06 sdetails
#450.06 sdetails
#460.06 sdetails
#470.06 sdetails
#480.06 sdetails
#490.07 sdetails
#500.06 sdetails
#510.06 sdetails
#520.06 sdetails
#530.07 sdetails
#540.06 sdetails
#550.06 sdetails
#560.06 sdetails
#570.06 sdetails
#580.06 sdetails
#590.06 sdetails
#600.06 sdetails
#610.06 sdetails
#620.06 sdetails
#630.06 sdetails
#640.06 sdetails
#650.06 sdetails
#660.06 sdetails
#670.06 sdetails
#680.06 sdetails
#690.06 sdetails
#700.06 sdetails

Code

import graphlib

n, m, x = [int(x) for x in input().split()]
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    graph[a-1].append(b-1)
answer = 'Yes'

def dfs_rec(graph, node, discovered, end, answer):
    discovered.add(node)

    for v in graph[node]:
        if v in discovered:
            answer = 'No'
            break
        
        if v not in end:
            a, b, answer = dfs_rec(graph, v, discovered, end, answer)
    
    discovered.remove(node)
    end.add(node)
    return discovered, end, answer

def dfs(graph, answer):
    discovered = set()
    end = set()

    for i in range(n):
        if i not in discovered and i not in end:
            discovered, end, answer = dfs_rec(graph, i, discovered, end, answer)
        if answer == 'No':
            break
    return answer

answer = dfs(graph, answer)

processed = set([])
order = []

def search_rec(x):
    for c in graph[x]:
        if c not in processed:
            search_rec(c)
    order.append(x)
    processed.add(x)

if answer == 'Yes':
    for i in range(n):
        if i not in processed:
            search_rec(i)
    
    dp = [0] * n
    for node in order:
        for nei in graph[node]:
            dp[node] += dp[nei] + 1
            if dp[node] > x:
                answer = 'No'
                break
        if answer == 'No':
            break

if sum(dp) > x:
    answer = 'No'

print(answer)

Test details

Test 1

Verdict:

input
2 1 7
1 2

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 2

Verdict:

input
2 1 7
2 1

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 3

Verdict:

input
3 3 6
2 1
2 3
1 3

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 4

Verdict:

input
3 2 10
2 3
2 1

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 5

Verdict:

input
3 3 4
3 1
3 2
1 2

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 6

Verdict:

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

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 7

Verdict:

input
4 4 1
3 2
3 4
1 2
2 4

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 8

Verdict:

input
4 3 8
1 2
4 1
4 3

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 9

Verdict:

input
4 4 7
4 3
1 2
2 4
2 1

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 10

Verdict:

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

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 11

Verdict:

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

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 12

Verdict:

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

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 13

Verdict:

input
5 7 10
2 4
3 2
3 5
3 1
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 14

Verdict:

input
5 7 6
2 3
1 5
5 2
5 1
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 15

Verdict:

input
5 10 8
4 1
4 3
4 2
4 5
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 16

Verdict:

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

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 17

Verdict:

input
5 10 8
1 3
1 5
1 2
1 4
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 18

Verdict:

input
5 4 8
1 3
2 4
2 1
3 4

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 19

Verdict:

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

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 20

Verdict:

input
5 4 6
2 5
2 1
5 1
5 4

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 21

Verdict:

input
10 29 2
10 3
10 1
10 8
10 7
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 22

Verdict:

input
10 24 2
8 2
8 9
8 5
8 4
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 23

Verdict:

input
10 25 10
10 2
10 6
10 3
2 5
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 24

Verdict:

input
10 29 6
10 8
10 6
10 5
8 10
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 25

Verdict:

input
10 44 8
10 3
10 9
10 1
10 6
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 26

Verdict:

input
10 17 7
3 8
6 5
6 2
9 3
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 27

Verdict:

input
10 42 8
9 7
9 8
9 6
9 10
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 28

Verdict:

input
10 11 8
5 7
9 5
7 10
7 8
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 29

Verdict:

input
10 41 5
9 1
9 5
9 3
9 6
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 30

Verdict:

input
10 9 6
3 1
3 4
3 8
1 7
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 31

Verdict:

input
100 484 159793364009
71 34
71 77
71 6
71 100
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 32

Verdict:

input
100 391 133876644548
80 94
80 38
80 72
80 79
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 33

Verdict:

input
100 405 903604029805
82 5
82 49
82 86
82 69
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 34

Verdict:

input
100 485 558765991856
50 14
50 99
50 67
50 63
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 35

Verdict:

input
100 777 785548293068
55 25
55 36
55 79
55 70
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 36

Verdict:

input
100 254 673064906661
52 69
52 1
52 27
62 92
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 37

Verdict:

input
100 725 776065552551
8 39
8 42
8 93
8 51
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 38

Verdict:

input
100 152 754385307168
25 97
25 35
25 95
77 49
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 39

Verdict:

input
100 712 484141188705
2 14
2 85
2 21
2 43
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 40

Verdict:

input
100 106 518519103960
35 52
35 65
35 1
10 90
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 41

Verdict:

input
200 968 159793364009
33 52
33 145
33 158
33 5
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 42

Verdict:

input
200 783 133876644548
191 46
191 148
191 172
191 199
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 43

Verdict:

input
200 810 903604029805
198 35
198 114
198 188
198 83
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 44

Verdict:

input
200 971 558765991856
15 135
15 69
15 26
15 165
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 45

Verdict:

input
200 1554 785548293068
2 47
2 103
2 25
2 84
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 46

Verdict:

input
200 510 673064906661
157 140
157 160
157 188
157 181
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 47

Verdict:

input
200 1450 776065552551
152 29
152 101
152 172
152 136
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 48

Verdict:

input
200 305 754385307168
109 147
56 74
56 7
56 15
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 49

Verdict:

input
200 1423 484141188705
143 29
143 176
143 14
143 76
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 50

Verdict:

input
200 213 518519103960
177 68
177 101
177 175
173 119
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 51

Verdict:

input
1000 4841 159793364009
576 121
576 902
576 377
576 491
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 52

Verdict:

input
1000 3918 133876644548
339 888
339 259
339 304
339 849
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 53

Verdict:

input
1000 4051 903604029805
35 303
35 119
69 585
69 445
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 54

Verdict:

input
1000 4855 558765991856
62 306
62 581
62 574
62 248
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 55

Verdict:

input
1000 7770 785548293068
884 615
884 721
884 158
884 812
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 56

Verdict:

input
1000 2553 673064906661
203 432
203 526
4 534
4 187
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 57

Verdict:

input
1000 7250 776065552551
39 227
39 503
39 293
39 680
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 58

Verdict:

input
1000 1533 754385307168
882 796
882 530
815 388
815 842
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 59

Verdict:

input
1000 7114 484141188705
32 267
32 642
32 225
32 548
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 60

Verdict:

input
1000 1071 518519103960
877 657
877 953
951 871
951 280
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 61

Verdict:

input
100000 154882 159793364009
52158 95830
52158 57997
10337 65466
10337 77949
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 62

Verdict:

input
100000 141702 133876644548
31918 98425
31918 27390
53839 48968
53839 65439
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 63

Verdict:

input
100000 143600 903604029805
58753 61357
58753 97879
58753 43009
77673 78316
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 64

Verdict:

input
100000 155080 558765991856
12714 27835
12714 87301
95755 24081
85090 72001
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 65

Verdict:

input
100000 196705 785548293068
64073 29701
64073 61899
64073 56663
64073 66942
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 66

Verdict:

input
100000 122199 673064906661
23466 47435
23466 38689
23466 81724
37777 76030
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 67

Verdict:

input
100000 189288 776065552551
56701 64161
56701 73527
56701 62864
25272 36550
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 68

Verdict:

input
100000 107630 754385307168
73409 77767
73409 20547
73409 2238
73409 7077
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 69

Verdict:

input
100000 187345 484141188705
66892 73373
62424 14951
73818 38984
73818 46385
...

correct output
No

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'

Test 70

Verdict:

input
100000 101036 518519103960
30507 31372
1379 74720
1379 56182
1379 8486
...

correct output
Yes

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import graphlib
ModuleNotFoundError: No module named 'graphlib'