Question: You are about to join a Guild. There are N potions in this guild, each with specific brewing requirements. You have been given a REQUIREMENTS
You are about to join a Guild. There are N potions in this guild, each
with specific brewing requirements. You have been given a REQUIREMENTS list of size Mwhere REQUIREMENTSi consists of PiQi indicating that potion Pi must be brewed before potion Qi can be concocted. In one brewing cycle, you can prepare at most K potions. Thus, you need to determine the minimum number of brewing cycles required to successfully concoct all potions.
Note: It is guaranteed that there is a feasible sequence to concoct all the potions. The most optimal solution is not required.
Format :
The first line of each test case contains three single spaceseparated integers NM and K represent the number of potions, number of repuirements, and maximum potions that you can brew in one brewing cycle respectively.
The next M line of each test case contains two single spaceseparated integers P and Q representing that the potion P must be concocted before the potion Q
Constraints:
N M N N
Q P and K N
Input :
Output :
Input :
Output :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
