PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#LCA0000085. Lưu lượng lớn nhất (Max Flow)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Lưu lượng lớn nhất (Max Flow)
Max Flow
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
There are stalls connected by pipes forming a tree. For each of pumping sessions, one unit of milk flows along the unique path from stall to stall , including both endpoints. Determine the maximum number of sessions passing through any single stall.
Input
First line: . Then edges and source-destination pairs .
Output
Print one integer: the maximum flow through any stall.
Subtasks
-
Subtask 1 (20 points): ; ; ; edges form a tree vô hướng.
-
Subtask 2 (30 points): ; ; ; edges form a tree vô hướng.
-
Subtask 3 (50 points): ; ; ; edges form a tree vô hướng.
Examples
Input
5 3
1 2
1 3
3 4
3 5
1 4
2 5
4 5
Output
3
Explanation
All three paths pass through stall , so its flow is , the maximum.