PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000011. Chuột thoát mê cung (Mice and Maze)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chuột thoát mê cung (Mice and Maze)
Mice and Maze
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Each of maze cells initially has one mouse. One-way passages have traversal times. Count mice able to reach exit cell within time , including the mouse already at .
Input
, exit , limit , and , followed by directed passages.
Output
Print the number of escaping mice.
Subtasks
- Subtask 1 (40 points): ; ; ; ; ; .
- Subtask 2 (60 points): ; ; ; ; .
Examples
Input
3
3
2
3
1 2 1
2 3 1
1 3 5
Output
3
Explanation
From cells , , and , the shortest times to exit are , , and respectively. All three escape.