Question: please provide a cpp code for the given problem You are about to join a Guild. There are N potions in this guild, each with

please provide a cpp code for the given problem
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 M, where REQUIREMENTS[i] consists of [Pi,Qi] indicating that potion Pi must be brewed before potion Qi can be brewed. In one brewing cycle, you can prepare at most K potions. Thus, you must determine the minimum number of brewing cycles required to brew all potions successfully.
Note: It is guaranteed that there is a feasible sequence to brew all the potions. The most optimal solution is not required.
Format :
The first line of each test case contains three single space-separated integers N,M and K, representing the number of potions, number of requirements, and maximum potions that you can brew in one brewing cycle, respectively.
The next M line of each test case contains two single space-separated integers P and Q representing that the potion P must be brewed before the potion Q.
Constraints:
1<= N <=15
0<= M <= N (N 1)/2
1<= Q, P and K <= N
Input :
432
21
31
14
Output :
3
Potion 1 can be brewed after potions 2 and 3 are brewed. Potion 4 can be brewed after
potion 1 is brewed.
Input :
542
21
31
41
15
Output :
4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!