Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem Description: Smoothie Expressway Due to the way customer lines like PA 2 are being managed, customers are becoming impatient, leading to a loss of
Problem Description: Smoothie Expressway Due to the way customer lines like PA are being managed, customers are becoming impatient, leading to a loss of clientele. The store managers of all of our stores in the city came to you with an idea to connect pairs of stores using a dedicated expressway. In that case if the waiting time is long in one store, customers can go from one store to another store using that expressway in a short amount of time without taking typical slower public road. Naturally, it would only be fair if each of the stores was connected to exactly one another. However, constructing those expressways are expensive. You have decided to proceed with the project only if the following conditions are met: There are n expressways connecting n stores. Each store is connected to only one expressway. The pairs of stores must be matched in a way that minimizes the total distance of the expressways. Assume that the distance of a expressway built between stores located at xi yi and xj yj is Write a program to determine this minimum sum of expressway distances so that your store managers are satisfied! The Problem Given the x y positions of n stores, of all possible ways to create n pairs of distinct stores, find the minimum possible sum of distances between each stores in the pairs. The Input to be read from standard input using scanf do not use file io Using file io will get zero The first line will contain a single positive integer, c c representing the number of test cases to process. The test cases follow. The first line of input for each case will contain a single positive integer, n n representing that there are n stores in total. The following n lines of each input case will contain a pair of space separated positive integers, xi and yi representing that the ith store is located at the coordinate xi yi with xi yi Additionally, the line will also contain the name of the store a single word string with maximum characters The Output to be printed in standard console output do not use file io Using file io will get zero For each input case, output a single floating point number rounded to exactly decimal places, representing the minimum sum of distances possible if the expressways are built between pairs of stores. After printing the sum, print n lines with the pairs store names and their distance that gave the minimum sum of distance. The output has to be in the following format: from store name, to store name, distance in exactly decimal places The "from store" should be the store that appeared first in the input compared to the to store". The order of the store names should match the order they appeared in the input. If multiple sets of pairs result in the same minimum distance, print only the set that comes first in the permutation based on the input order. Ensure your output exactly matches CodeGrade's output. Sample Input STOREA STOREB SMOTHIEKING SMOTHIEQUEEN SMOOTHIEPRINCE SMOOTHIEPRINCES SMOTHIEPALACE SMOTHIEKINGDOM Sample Output STOREA STOREB, SMOTHIEKING SMOTHIEQUEEN, SMOOTHIEPRINCE SMOOTHIEPRINCES, SMOTHIEPALACE SMOTHIEKINGDOM, Implementation Restrictions You must use the permutation used array technique in your solution There are three tiers of credit for this program. If you can get the code to run fast enough for n then that's worth of the points. If you can get it to run fast enough for n that's worth of the points, and for full credit, it has to run fast for n For most part of the code like for n you are not allowed to use chatgpt. You should use the permuation code discussed in the class and modify it to solve this problem. However, for optimizing the code for n or more, you must explore how chatgpt can help you to optimize your code and you must submit a report with your finding that should contain: a Your code that runs fast enough for n b Screenshot of the prompt and response from chagpt that helped you to improve your code to run faster with n or more. It's completely okay if you don't find a solution that runs fast enough for n You will not lose much credit. My expectation is that students will be able to solve the problem for n I am curious to see how many can solve it for n and n Your permutation must be a recursive code. You are allowed to use only two global variables. No other global variables are allowed: a One for array of stores b One for the final set of permutation int array that stores the index of the stores that gave you the minimum distance Deliverables You must submit four files over codegrade: A source file, main.c A file describing how you have used chatgpt to optimize your code for n
Problem Description: Smoothie Expressway
Due to the way customer lines like PA are being managed, customers are becoming impatient, leading to a loss of clientele.
The store managers of all of our stores in the city came to you with an idea to connect pairs of stores using a
dedicated expressway. In that case if the waiting time is long in one store, customers can go from one store to
another store using that expressway in a short amount of time without taking typical slower public road. Naturally,
it would only be fair if each of the stores was connected to exactly one another. However, constructing those
expressways are expensive. You have decided to proceed with the project only if the following conditions are met:
There are n expressways connecting n stores.
Each store is connected to only one expressway.
The pairs of stores must be matched in a way that minimizes the total distance of the expressways.
Assume that the distance of a expressway built between stores located at xi yi and xj yj is
Write a program to determine this minimum sum of expressway distances so that your store managers are
satisfied!
The Problem
Given the x y positions of n stores, of all possible ways to create n pairs of distinct stores, find the minimum
possible sum of distances between each stores in the pairs.
The Input to be read from standard input using scanf do not use file io Using file io will get zero
The first line will contain a single positive integer, c c representing the number of test cases to process.
The test cases follow.
The first line of input for each case will contain a single positive integer, n n representing that there are n
stores in total.
The following n lines of each input case will contain a pair of space separated positive integers, xi and yi
representing that the ith store is located at the coordinate xi yi with xi yi Additionally, the
line will also contain the name of the store a single word string with maximum characters
The Output to be printed in standard console output do not use file io Using file io will get zero
For each input case, output a single floating point number rounded to exactly decimal places, representing the
minimum sum of distances possible if the expressways are built between pairs of stores. After printing the sum,
print n lines with the pairs store names and their distance that gave the minimum sum of distance. The output has
to be in the following format: from store name, to store name, distance in exactly decimal places The "from store"
should be the store that appeared first in the input compared to the to store". The order of the store names should match the
order they appeared in the input. If multiple sets of pairs result in the same minimum distance, print only the set that comes
first in the permutation based on the input order. Ensure your output exactly matches CodeGrade's output.
Sample Input
STOREA
STOREB
SMOTHIEKING
SMOTHIEQUEEN
SMOOTHIEPRINCE
SMOOTHIEPRINCES
SMOTHIEPALACE
SMOTHIEKINGDOM
Sample Output
STOREA STOREB,
SMOTHIEKING SMOTHIEQUEEN,
SMOOTHIEPRINCE SMOOTHIEPRINCES,
SMOTHIEPALACE SMOTHIEKINGDOM,
Implementation Restrictions
You must use the permutation used array technique in your solution
There are three tiers of credit for this program. If you can get the code to run fast enough for n then that's
worth of the points. If you can get it to run fast enough for n that's worth of the points, and for
full credit, it has to run fast for n
For most part of the code like for n you are not allowed to use chatgpt. You should use the permuation
code discussed in the class and modify it to solve this problem. However, for optimizing the code for n or
more, you must explore how chatgpt can help you to optimize your code and you must submit a report with
your finding that should contain:
a Your code that runs fast enough for n
b Screenshot of the prompt and response from chagpt that helped you to improve your code to run faster
with n or more.
It's completely okay if you don't find a solution that runs fast enough for n You will not lose much credit.
My expectation is that students will be able to solve the problem for n I am curious to see how many can
solve it for n and n
Your permutation must be a recursive code.
You are allowed to use only two global variables. No other global variables are allowed:
a One for array of stores
b One for the final set of permutation int array that stores the index of the stores that gave you the
minimum distance
Deliverables
You must submit four files over codegrade:
A source file, main.c
A file describing how you have used chatgpt to optimize your code for n
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started