A higher resolution is required to access the IDE
- 81
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
You are given n_imp lines, each representing a library import in python style. Then, n_dep lines for the dependencies between libraries. Then, step by step you have to:(1) Assess if the code will run successfully as it is. If so, print
(2) If the code doesn't run successfully, find where the first* error is located, print the line
(2.1) If it can be fixed by reordering the imports, find the only order such that at any time, among the possible importable libraries, the smallest (lexicographically) module is chosen.
The format will be, the line:
(2.2) If the error is not salvageable return the message
* The imaginary compiler will import the libraries in the order that they are given by the puzzle until it finds one that requires a library that was not previously imported.
Input
Line 1: An integer n_imp for the number of libraries to import.
Next n_imp lines: A python-like declaration for a library import.
Next line: An integer n_dep for the number of dependency relation between libraries.
Next n_dep lines: A string representing a dependency relation between libraries.
A dependency relation is given in the format:
libraryrequires library1 [, library2, library3 ... ]
Next n_imp lines: A python-like declaration for a library import.
Next line: An integer n_dep for the number of dependency relation between libraries.
Next n_dep lines: A string representing a dependency relation between libraries.
A dependency relation is given in the format:
library
Output
The compilation log as defined in the statement, one log message per line.
Constraints
Example
Input
3 import A import B import C 2 B requires A C requires B
Output
Compiled successfully!
A higher resolution is required to access the IDE