PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#LCA0000082. Sửa cầu (Bridge Repairs)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sửa cầu (Bridge Repairs)
Bridge Repairs
Source: VNOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Pirate lives on islands connected by bridges forming a tree. On each of days he inspects every bridge on the unique route between islands and . Count bridges that were never inspected. Repeated inspection does not increase the number of inspected bridges.
Input
First line: . Next lines: edges . Then , followed by pairs .
Output
Print one integer: the number of bridges never inspected.
Subtasks
-
Subtask 1 (20 points): ; ; ; edges form a tree.
-
Subtask 2 (30 points): ; ; ; edges form a tree.
-
Subtask 3 (50 points): ; ; ; edges form a tree.
Examples
Input
6
1 2
2 3
2 4
4 5
4 6
2
3 6
5 6
Output
1
Explanation
The first journey inspects bridges , , ; the second inspects , . Only bridge remains uninspected.