• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Занятие 8. Dictionary

Difficulty level:

Task«Do you need a dictionary?»

You are developing a system for analyzing dependencies between the modules of the software project. Each module can depend on other modules, and you need to build a dependence graph, identify cyclic dependencies and determine the correct procedure for loading the modules.
rn
The system should calculate the level of each module (the maximum depth of the dependence chain to it) and perform topological sorting to determine the safe loading order.

Input format

the first line contains the number n-the number of modules.
The following n strings; They contain a description of dependencies in the format:
name_modula: dependence1 dependence2 ... Dependence
rn

Output format


cycle Detiateded rn
Otherwise:
rn
    rn
  • rn
    line with the procedure for loading modules through a gap
  • rn
  • rn
    n lines in format & nbsp; module Level
    rn
  • rn

Example

Input

4
Main: Utils Database
Utils: Config
Database: Config
config:

Output

config utils database main
config: 0
utils: 1
daatabase: 1
main: 2

Hint

There will be no clue here, decide for yourself!

main.py
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Developer’s solution

🎉 Congratulations! 🎉

You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

AD

Advertisement

red-snake blue-snake green-snake

Running your code...

Помощник ИИ

Привет! Я твой помощник по программированию. Задавай любые вопросы по Python, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!