Question: In C++, this is all the info I got Problem 1: Resources Michael is an economist who researches the impact of various industries on the



In C++, this is all the info I got
Problem 1: Resources Michael is an economist who researches the impact of various industries on the natural environment. He wants to know if a certain industry has negative consequences on the environment, such as releasing non-decomposable materials, or if it creates a cycle with the natural environment. If an industry produces non-decomposable materials and no cycle of resource transformation can be found, Michael wants to know what is the length of the longest chain of transformation from base resource to non-decomposable materials. Data format: Input The input file is called resources.in". The first line contains the number of resources N. The second line contains N names representing the names of each resource. Then on the next N lines: line i contains the name of the parent resource for the resource that has the index i. Output The output file is called "resources.out". If a natural cycle has been detected, then the message "Cycle detected!" will be written on the first line of the output file. If there is no natural cycle detected, then the length of the longest chain of resource transformation will be written on the first line of the output file. Data limits: 1 Plastics -> Bottles -> Microplastics Example 2: resources.in resources.out 4 Cycle detected! ABCD C A B Base Base DIE B D Explanation - Example 2: Resources A, B and C form a natural cycle
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
