PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000015. Đội đặc nhiệm (Commandos)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đội đặc nhiệm (Commandos)
Commandos
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Buildings are connected by undirected unit-time corridors. A team begins at , must cover all buildings and reassemble at , with arbitrarily many agents allowed in parallel. Find the minimum total mission time.
Input
, then undirected edges with zero-based endpoints; finally .
Output
Print the minimum mission time.
Subtasks
- Subtask 1 (40 points): ; ; ; ; đồ thị liên thông.
- Subtask 2 (60 points): ; ; ; đồ thị liên thông.
Examples
Input
4 3
0 1
1 2
2 3
0 3
Output
3
Explanation
For each building on the chain, , so the mission completes in time units.