PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000010. Đỉnh ở quá xa (A Node Too Far)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đỉnh ở quá xa (A Node Too Far)
A Node Too Far
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
In an undirected network, a message from node may traverse at most edges. Count nodes that cannot be reached within this limit; an absent source reaches none.
Input
undirected endpoint pairs followed by source and TTL .
Output
Print the number of unreachable nodes within TTL.
Subtasks
- Subtask 1 (40 points): at most distinct network labels; ; ; .
- Subtask 2 (60 points): ; ; .
Examples
Input
3
10 20
20 30
30 40
10 1
Output
2
Explanation
With TTL , only nodes 10 and 20 are reachable from 10; nodes 30 and 40 are not.