Samarth and Soham decide to have another shot at the Tour de France. This time there...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Samarth and Soham decide to have another shot at the Tour de France. This time there are various checkpoints on the roads in Paris. All the roads are 2-way. After cycling for 10 hours Samarth realizes that they have cycled past the Eiffel Tower too many times. Soham then exclaims, we have been cycling in cycles. Soham now wants to find out how many simple cycles exist, but Samarth wants to find out which checkpoints are part of these cycles. Can you help them figure this out and reach the finish. A simple cycle is a path(at least one road) from a checkpoint to itself visiting other checkpoints atmost once such that no subset of the checkpoints can form a cycle themselves. • Input First line of input consists of two integers N and M which denote the number of checkpoints and the number of roads respectively. The next 2 lines consist of two arrays A and B of size M, which means that there is a road between checkpoint A[i] and B[i] for every 1 ≤ i ≤ M • Output Output the number of simple cycles. In the next line output N integers which are either 1 or 0 such that 1 at ith position indicates that ith checkpoint is a part of one or more cycles, whereas 0 indicates that it is part of no cycles. Constraints 0 1 ≤N ≤ 105 0 0 ≤M ≤ min(N * (N − 1)/2, 105) o 1 ≤ A[i], B[i] ≤ N Vi € [1, N] • Sample Input 1 8 10 1 1 1 7 7 5 8 2 26 2 3 4 1 5 6 4 3 77 • Sample Output 1 3 1 1 1 0 1 1 1 0 • Sample Input 2 77 1 3 3 2 6 5 2 2 2 4 5 5 7 4 • Sample Output 2 1 0 1 1 1 0 0 0 Explanation of Input 1 The map of Paris of Input 1 looks as follows 8 7 3 2 Here there are 3 simple cycles viz. {1,2,3}, {1,2,7}, {5,6,7} Here all checkpoints except 4 and 8 are part of cycles Samarth and Soham decide to have another shot at the Tour de France. This time there are various checkpoints on the roads in Paris. All the roads are 2-way. After cycling for 10 hours Samarth realizes that they have cycled past the Eiffel Tower too many times. Soham then exclaims, we have been cycling in cycles. Soham now wants to find out how many simple cycles exist, but Samarth wants to find out which checkpoints are part of these cycles. Can you help them figure this out and reach the finish. A simple cycle is a path(at least one road) from a checkpoint to itself visiting other checkpoints atmost once such that no subset of the checkpoints can form a cycle themselves. • Input First line of input consists of two integers N and M which denote the number of checkpoints and the number of roads respectively. The next 2 lines consist of two arrays A and B of size M, which means that there is a road between checkpoint A[i] and B[i] for every 1 ≤ i ≤ M • Output Output the number of simple cycles. In the next line output N integers which are either 1 or 0 such that 1 at ith position indicates that ith checkpoint is a part of one or more cycles, whereas 0 indicates that it is part of no cycles. Constraints 0 1 ≤N ≤ 105 0 0 ≤M ≤ min(N * (N − 1)/2, 105) o 1 ≤ A[i], B[i] ≤ N Vi € [1, N] • Sample Input 1 8 10 1 1 1 7 7 5 8 2 26 2 3 4 1 5 6 4 3 77 • Sample Output 1 3 1 1 1 0 1 1 1 0 • Sample Input 2 77 1 3 3 2 6 5 2 2 2 4 5 5 7 4 • Sample Output 2 1 0 1 1 1 0 0 0 Explanation of Input 1 The map of Paris of Input 1 looks as follows 8 7 3 2 Here there are 3 simple cycles viz. {1,2,3}, {1,2,7}, {5,6,7} Here all checkpoints except 4 and 8 are part of cycles
Expert Answer:
Answer rating: 100% (QA)
Samarth and Soham decide to have another shot at the Tour de France This time there are various chec... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
A car of mass 1 3 0 1 kg , is initially travelling at 2 1 . 3 ms - 1 . Calculate the kinetic energy of the vehicle in kJ to the nearest whole number.
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
We will be working with a company called Global Bike Inc., (GBI). Information regarding GBI follows. Company History Global Bike Inc. has a pragmatic design philosophy that comes from its deep roots...
-
O An hair dryer is basically a duct with a fan that draws cool air from the atmosphere at one end, forces it on an electrical resistor (where the air is heated up) and discharges it at the other end....
-
Carbon dioxide at high pressure is used to separate various compounds in citrus oil. The mole fraction of CO, in the liquid (x) and vapour (y) at 323.2 K is given below for a variety of pressures (Y....
-
Fisherman makes high-end surgical instruments for use by medical professionals. Not long after the company opened, it contracted with a medical supply dealer, Trianim, to sell its instruments to...
-
Explain the terms corporate negligence, respondeat superior, and independent contractor.
-
A school district receives a grant from the federal government to support programs directed at special needs students. The grant is a matching grant in which each dollar spent by the school district...
-
History Netflix was started in 1997 in Scott Valley, CA by Reed Hastings, and Marc Randolph. Reed and Marc wanted people to be able to rent DVDs by mail. A year later, in 1998, Netflix.com was...
-
When Corona leased farmland to a strawberry farmer named Armando Munoz Juarez, it claimed a security interest in his strawberry crop. Coronas financing statement listed the farmers name as Armando...
-
An experiment is set-up with a monochromatic light source, a double slit, and a screen, similar to what is shown on page 7-2 of your lab manual. The experimenter measures and sketches the intensity...
-
Write program in Java. You work for a package shipping company and are writing a program to determine shipping rates. The rates are determined by the following rules: If a package weighs less than 16...
-
12. Write Python code that takes a number in base 2 as a string and converts it into a number in base 10. The name of the function is convert. Here is the output: 1 def convert(xstring): 2 #TO DO:...
-
Why is it not possible to have 100% confidence? Explain. (Choose Best Answer Below) a.)A 100% confidence interval is not possible unless either the entire population is sampled or an absurdly wide...
-
Yield to maturity (%) 5.25 5.50 6.00 The following table provides details on three bonds that each have a par value of $100. Assuming annual coupons, what is the forward rate between years 2 and 3?...
-
A fundamental to OS design, is concurrency. What is Concurrency? What are the three contexts causes Concurrency? QUESTION 2: What are the Principles of Concurrency in OS ? QUESTION 3: What is...
-
For the year ended December 31, 2020, Prunus, Inc., reported net income before federal income tax expense of $800,000 per the corporation's books. This figure included the following items: Interest...
-
Reconsider Prob. 1474. In order to drain the tank faster, a pump is installed near the tank exit as in Fig. P1475. Determine how much pump power input is necessary to establish an average water...
-
How has human resource managements evolution over the years helped to make it a better partner to the business? In what way would you expect HRM to continue to evolve over the years?
-
Your companys founder believes that younger workers are more energetic and serve better in sales positions. Before posting a new job ad for your sales division, he recommends that you list an age...
-
What is organizational change?
-
A \(40-\mathrm{cm}-\) long tube has a \(40-\mathrm{cm}-\) long insert that can be pulled in and out, as shown in Figure P16.59. A vibrating tuning fork is held next to the tube. As the insert is...
-
The width of a particular microwave oven is exactly right to support a standing-wave mode. Measurements of the temperature across the oven show that there are cold spots at each edge of the oven and...
-
A \(12 \mathrm{~kg}\) hanging sculpture is suspended by a \(90-\mathrm{cm}-\) long, \(5.0 \mathrm{~g}\) steel wire. When the wind blows hard, the wire hums at its fundamental frequency. What is the...
Study smarter with the SolutionInn App