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

Simple Scheduling Problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 371    Accepted Submission(s): 129


Problem Description
Team YouAreSoStrong meet a very boring problem. They have to schedule n jobs on m machines. Each job needs exactly one unit time on one machine. At first, YouAreSoStrong thought ceil(n/m) units of time is enough. Soon, they find out there exist some ordering constraints between jobs. This is reasonable. For example, you have to complete "hand in hand" before you can "hug". And only after you've done "hug", can you "kiss". It's guaranteed that following 3 conditions are satisfied.
1. one job can only be relied by at most one job.
2. one job may rely more than one job.
3.There is no circular dependency. Such as a relies on b, and b relies on a.
YouAreSoStrong thought for a long time, but do not have a clue. Can you help them?
 

Input
First line contains one integer T, indicates the number of test cases. For each case, the first line contains 3 integers : n, e, m, denotes number of jobs, number of ordering constraints, number of machines separately. Each line from 2 to (e+1)th contains one pair of integers (a,b), which stands for job a must be done before job b can start. T¡Ü10. 0 < n, e , m¡Ü100 000.

 

Output
Print one integer on one line for each case, which is the minimum units of time YouAreSoStrong can schedule all the jobs.

 

Sample Input
2 4 2 1 1 3 2 3 4 2 2 1 3 2 3
 

Sample Output
4 2
 

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-05-12 08:42:00, Gzip enabled