Security Badge
Time limit3sMemory limit512 MB
Given a directed graph whose edges each allow a range of badge IDs, count the badge IDs x for which room t is reachable from s.
- Level
Medium7 of 10
- Topics
- Graph, BFS, Intervals, Implementation
- Solved
- No attempts yet
Problem
You are in charge of security for a large building with rooms and doors between the rooms. Rooms are numbered 1 to , and doors are numbered 1 to .
Door opens from room to room and not the other way around. Every door has a security code given as a range of integers .
There are employees in the building. Each employee carries a security badge, and the badge IDs are distinct integers between 1 and . An employee whose badge ID is goes through door only when .
Your boss wants a quick check of the building's security. Given and , how many employees can get from room to room ?
Input
The first line contains three space separated integers , , and (, , ).
The second line contains two space separated integers and (, ).
Each of the next lines contains four space separated integers , , , and describing door (, , ).
For any two rooms and there is at most one door from to , but a door from to and a door from to may both exist.
Output
Print, on a single line, the number of employees who can reach room starting from room .