|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||256 MB||31||16||15||50.000%|
Once again you lost days refactoring code, which never runs in the first place. Enough is enough – your time is better spent writing a tool that finds unused code!
Your software is divided into packages and executables. A package is a collection of methods. Executables are packages defining among other methods exactly one method with name
PROGRAM. This method is executed on the start of the corresponding executable. Ordinary packages have no method named
Each method is uniquely identified by the combination of package and method names. E.g. the method with the identifier
SuperGame::PROGRAM would be the main method of the executable
For every method in your software you are given a list of methods directly invoking it. Thus you can easily identify methods, that are never called from any method. However, your task is more challenging: you have to find unused methods. These are methods that are never reached by the control flow of any executable in your software.
The first line of the input contains an integer N, the number of methods in your software (1 ≤ N ≤ 400).
Each method is described by two lines, totaling in 2·N lines. The first line consists of the unique identifier of the method and ki, the number of methods directly invoking this one (0 ≤ ki ≤ N). The second line consists of a set of ki identifiers of these calling methods or is empty if there are no such methods, i.e. ki = 0.
Method identifiers consist of a package name followed by two colons and a method name like
Packagename::Methodname. Both strings, the package and the method name, each consist of up to 20 lowercase, uppercase characters or digits (a-z, A-Z, 0-9).
There will be exactly N different method identifiers mentioned in the input.
A line containing the number of unused methods in your software.
2 SuperGame::PROGRAM 0 HelpPackage::HelpFunction 2 HelpPackage::HelpFunction SuperGame::PROGRAM
2 Loop::CallA 1 Loop::CallB Loop::CallB 1 Loop::CallA
2 SuperGame::PROGRAM 1 SuperServer42::PROGRAM SuperServer42::PROGRAM 1 SuperServer42::PROGRAM