Hacking
InterviewTime limit2sMemory limit256 MB
Starting from the hacked computer, count reachable computers through dependency edges and report the longest infection time.
- Level
Medium4 of 10
- Topics
- Shortest path, Graph, Heap
- Solved
- No attempts yet
Problem
A hacker compromises one computer in a network. If computer a depends on computer b, then once b is infected, computer a becomes infected after s seconds.
Given the hacked computer and all dependencies, report how many computers become infected and how long until the last infection.
Input
The first line contains test cases (). Each test case starts with , , and , followed by lines with , , and meaning a depends on b.
Output
For each test case, print the number of infected computers and the time of the last infection.