Write a C++ programme There are friends_nodes friends, numb 1 to friends nodes, who like to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C++ programme There are friends_nodes friends, numb 1 to friends nodes, who like to eat Open with different candies. There are friends gan pairs of friends where each pair of friends is connected by the common candy that they both like. Candies are numbered from 1 to 100. Note that if x[i] and y[i] are connected by a candy c[i] and y[i] and z[i] are also connected by the candy c[i], then x[i] and z[i] are also said to be connected by c[i]. Find the maximal product of x[i] and y[i] so that x[i] and y[i] share the largest group of friends which is connected by some common candy. As an example, assume the following 6 inputs: From To Candy 2 51 3 51 6 51 8 51 9 51 3 51 1 7 5 10 6 2 Everyone likes the same candy, but not everyone is connected. A graphical representation is: The largest group is [1, 2, 3, 7] and its largest elements are 3 and 7. Their product is 21. Function Description Complete the function countCandies in the editor below. The function must return an integer that represents to page dunt of the maximumovo frend numbers in the largest group. countCandies has the following parameter(s): friends_nodes: an integer, the number of friends friends from[friends_from[0],...friends_from[n-1]]: an integer array where each element denotes the first friend in the pair friends_to[friends_to[0]....friends_to[n-1]]: an integer array where each element denotes the second friend in the pair friends_weight[friends_weight[0]....friends_weight[n-1]]: an integer array where each element denotes a candy liked by both friends Constraints 2 ≤ friends_nodes ≤ 100 1 s friends_edges s min (200, 1 ≤ friends_weight[i] ≤ 100 1 s friends_from[i], friends_to[i] ≤ friends_nodes 1s friends_weight[i] ≤ friends_edges friends from[i]#friends_to[i] Each pair of friends can be connected by more than one type of candy + Write a C++ programme There are friends_nodes friends, numb 1 to friends nodes, who like to eat Open with different candies. There are friends gan pairs of friends where each pair of friends is connected by the common candy that they both like. Candies are numbered from 1 to 100. Note that if x[i] and y[i] are connected by a candy c[i] and y[i] and z[i] are also connected by the candy c[i], then x[i] and z[i] are also said to be connected by c[i]. Find the maximal product of x[i] and y[i] so that x[i] and y[i] share the largest group of friends which is connected by some common candy. As an example, assume the following 6 inputs: From To Candy 2 51 3 51 6 51 8 51 9 51 3 51 1 7 5 10 6 2 Everyone likes the same candy, but not everyone is connected. A graphical representation is: The largest group is [1, 2, 3, 7] and its largest elements are 3 and 7. Their product is 21. Function Description Complete the function countCandies in the editor below. The function must return an integer that represents to page dunt of the maximumovo frend numbers in the largest group. countCandies has the following parameter(s): friends_nodes: an integer, the number of friends friends from[friends_from[0],...friends_from[n-1]]: an integer array where each element denotes the first friend in the pair friends_to[friends_to[0]....friends_to[n-1]]: an integer array where each element denotes the second friend in the pair friends_weight[friends_weight[0]....friends_weight[n-1]]: an integer array where each element denotes a candy liked by both friends Constraints 2 ≤ friends_nodes ≤ 100 1 s friends_edges s min (200, 1 ≤ friends_weight[i] ≤ 100 1 s friends_from[i], friends_to[i] ≤ friends_nodes 1s friends_weight[i] ≤ friends_edges friends from[i]#friends_to[i] Each pair of friends can be connected by more than one type of candy +
Expert Answer:
Answer rating: 100% (QA)
NOTE Since the programming language is not mentioned below code is written in python language Start ... View the full answer
Posted Date:
Students also viewed these programming questions
-
N sources of current with different emf's are connected as shown in Fig. 3.40. The emf's of the sources are proportional to their internal resistances, i.e. ε = aR, where a is an assigned...
-
If [x] denotes the greatest integer function, find lim x x/[x].
-
In Figure an array of n parallel resistors is connected in series to a resistor and an ideal battery. All the resistors have the same resistance. If an identical resistor were added in parallel to...
-
Compute the determinant below. 14 8 8 8 51 1000 8 7 3 0 0 0 8 8 8 8 8 2
-
Using the data in Table 116 on page 300, indicate the closing dollar value of the National City Corp. bonds that pay 4.9 percent interest and mature January 15, 2015. State your answer in terms of...
-
Indicate the section of an income statement in which each of the following is shown, (a) Loss on inventory write-down. (b) Loss from strike. (c) Bad debt expense. (d) Loss on disposal of a component...
-
A positively charged particle located at the origin of an \(x y z\) coordinate system spins about the \(z\) axis, and the spin is counterclockwise when viewed looking down from the positive \(z\)...
-
Ten interrelated elements that are most directly related to measuring the performance and financial status of an enterprise are provided below. Identify the element or elements associated with the 12...
-
QUESTION TWO a) State and explain five monetary policy instruments used by the central bank to regulate interest rate, inflation rate, exchange rate and the quantity of money in the economy [15...
-
Is the mean or the median more likely to provide a better measure of typical sales revenue for companies included in the Fortune 500?
-
Identify a book where all the transactions are recorded first. a. Profit and Loss statement O b. Balance sheet c. Ledger O d. Journal
-
Your company has sales of $103,600 this year and cost of goods sold of $60,300. You forecast sales to increase to $117,700 next year. Using the percent of sales method, forecast next years cost of...
-
Your firm currently has net working capital of $111,000 that it expects to grow at a rate of 5% per year forever. You are considering some suggestions that could slow that growth to 3% per year. If...
-
Your supplier offers terms of 3/20, net 30. What is the effective annual cost of trade credit if you choose to forgo the discount and pay on day 30?
-
Assume the credit terms offered to your firm by your suppliers are 4/15, net 60. Calculate the cost of the trade credit if your firm does not take the discount and pays on day 60.
-
The following information pertains to Alpha Corporation whose functional currency is the dollar. Required Assume that Alpha Corporation designates the forward contract as a fair value hedge of the...
-
Definitions of the key terms such as Corporate Social Responsibility (CSR) and Diversity/Equity/Inclusion (DEI) and other background information you care to share explaining the importance of the two...
-
Linda Lopez opened a beauty studio, Lindas Salon, on January 2, 2011. The salon also sells beauty supplies. In January 2012, Lopez realized she had never filed any tax reports for her business and...
-
The manager of the 'D' Division is considering investing in a replacement machine at the beginning of next year, 2020. If the investment does not go ahead, then the divisional results for '...
-
Nielsen Ltd has two divisions with the following information: Division A has been offered a project costing $\$ 100,000$ and giving annual returns of $\$ 20,000$. Division $B$ has been offered a...
-
Division A has been offered a project costing $\$ 100,000$ and giving annual returns of $\$ 20,000$. Division $B$ has been offered a project costing $\$ 100,000$ and giving annual returns of $\$...
Study smarter with the SolutionInn App