F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Paths on the tree

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 2853    Accepted Submission(s): 888


Problem Description
bobo has a tree, whose vertices are conveniently labeled by 1,2,¡­,n.

There are m paths on the tree. bobo would like to pick some paths while any two paths do not share common vertices.

Find the maximum number of paths bobo can pick.
 

Input
The input consists of several tests. For each tests:

The first line contains n,m (1¡Ün,m¡Ü105). Each of the following (n - 1) lines contain 2 integers ai,bi denoting an edge between vertices ai and bi (1¡Üai,bi¡Ün). Each of the following m lines contain 2 integers ui,vi denoting a path between vertices ui and vi (1¡Üui,vi¡Ün).
 

Output
For each tests:

A single integer, the maximum number of paths.
 

Sample Input
3 2 1 2 1 3 1 2 1 3 7 3 1 2 1 3 2 4 2 5 3 6 3 7 2 3 4 5 6 7
 

Sample Output
1 2
 

Author
Xiaoxu Guo (ftiasch)
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-10-31 09:11:34, Gzip enabled