## CSCI-570 Homework 4

算法编程课业代写 1 Compute Max-Flow And Min-Cut 2 Escape From the Building In this problem, we need to decide whether there is a feasible plan for all the

**1 Compute Max-Flow And Min-Cut **

**1 Compute Max-Flow And Min-Cut**

**2 Escape From the Building **

**2 Escape From the Building**

In this problem, we need to decide whether there is a feasible plan for all the persons in a building to escape when they meet some emergency issues. More specifically, a building is described as an * n *by

*grid and the position of*

*n**persons are represented as the integer points (*

*p*

*x*_{1}

*, y*_{1})

*(*

*, . . . ,*

*x*

_{p}

*, y**) in the building. Note that to ensure safety, we don’t allow any intersection between the paths of any two person. Therefore, your task is to decide whether there exist*

_{p}*vertex-disjoint paths from their starting points to any*

*p**different points on the boundary of the grid. Give an algorithm polynomial in*

*p**and prove the correctness of it.*

*n*** **

**3 Install Software to Your New Computer 算法编程课业代写**

**3 Install Software to Your New Computer 算法编程课业代写**

Suppose that you have just bought a new computer and you want to install software on that. Specifically, two companies, which you can think of like Microsoft and Apple, are trying to sell their own copy of * n *different products, like Operation System. Spread Sheet, Web Browser. For each product

*,*

*i*

*i**1*

*∈ {**2*

*,*

*, . . . , n**, we have*

*}**p*_{i}0 that Microsoft charges and the price*≥**p**’*_{i}0 that Apple charges.*≥**q**i*0 of Microsoft version and the quality*≥**q**’*_{i}0 of Apple version.*≥*

For example, Apple may provide a better Web Browser Safari, but Microsoft a better Word Processor. You want to assemble your favorite computer by installing exactly one copy of each of the * n *products, e.g. you want to buy one operating system, one Web Browser, one Word Processor, etc. However, you don’t want to spend too much money on that. Therefore, your goal is to maximize the quality minus total price.

#### However, as you may know, the products of different companies may not be compatible. 算法编程课业代写

More concretely, for each product pair (* i, j*), we will suffer a penalty

*τ*

_{ij}

*0 if we install product*

*≥**of Microsoft and product*

*i**of Apple. Note that*

*j*

*τ*

_{ij}*may not be equal to*

*τ*

_{ji}*just because Apple’s Safari does not work well on Microsoft Windows doesn’t mean that Microsoft’s Edge does not work well in Mac-OS. We assume that products are always compatible internally, which means that there is no penalty for installing two products from the same company. All pairwise penalties will be subtracted from the total quality of the system.*

Your task is then to give a polynomial-time algorithm for computing which product * i *to purchase from which of the two companies (Apple and Microsoft) for all

*i**1*

*∈ {**2*

*,*

*, . . . , n**, to maximize the total system quality (including the penalties) minus the total price. Prove the correctness of your algorithm. (Hint: You may model this problem as a min-cut problem by constructing your graph appropriately.)*

*}*** **

**4 Jumping Frogs 算法编程课业代写**

**4 Jumping Frogs 算法编程课业代写**

Somewhere near the Algorithmville, a number of frogs are standing on a number of lotus leaves. As they are social animals (and yes, they are never infected by coronavirus!), the frogs would like to gather together, all on the same lotus leaf. The frogs do not want to get wet, so they have to use their limited jump distance * d *to get together by jumping from piece to piece. However, these lotus leaves just started to grow, they will get damaged further by the force needed to jump to another leaf. Fortunately, the frogs are real experts on leaves, and know exactly how many times a frog can jump off each leaf before it sinks and become unavailable. Landing on leaves does not damage it. You have to help the frogs find a leaf where they can meet.

In this question, we will get the position of * N *lotus leaves. For each

*i**[*

*∈**], we know its position (*

*N*

*x*

_{i}

*, y**), the number of frogs*

_{i}

*n*

_{i}*on that leaf and the number of jumps*

*m*

_{i}*before it sinks. The distance between two leaves (*

*x*

_{i}

*, y**) and (*

_{i}

*x*

_{j}

*, y*

_{j}*) is defined as*

*|*

*x*

_{i}

*−*

*x*

_{j}

*+*

*|*

*|*

*y*

_{i}

*−*

*y*

_{j}

*. Design an polynomial algorithm to determine whether each lotus leaf can hold all frogs for a party. The output is an array with length*

*|**, containing yes/no solution.*

*N*** **

**5 Preparing for the Exams 算法编程课业代写**

**5 Preparing for the Exams 算法编程课业代写**

My friend Leo wants to have a emergency plan for his final exams on University of Southern Algorithmville. He has * N *subjects to prepare for, and for each subject, his score is determined only by the time he spend on learning. It’s not surprising that Leo found out he actually spent

**time on preparing before.**

**zero**At least he knows when he can start learning all of these subjects. For each subject * i *there is a start time

*s*_{i}*when he can get all materials ready to start learning. And there is also a ending time*

*e*_{i}*for each subject. When his learning materials expire and he can’t learn anymore. We know that*

*s**and*

*i*

*e**are integers, and Leo can only dedicate to a single subject within each time phase.*

*i*In the University of Southern Algorithmville (USA), a student’s total grade is the minimum grade among all subjects. Leo wants you to help him find out the best outcome. Given * N *subjects and their time intervals (

*s*

_{i}

*, e**), design an algorithm to find out the maximum time possible for the least prepared subject. (Hint: It’s not enough to use the network flow algorithm alone to determine the answer.)*

_{i}** **

**6 Help Kumiko! 算法编程课业代写**

**6 Help Kumiko! 算法编程课业代写**

Kumiko is a member of a high school music group and she is in charge of counting the monthly community fee for each members. This work should be easy but the members are trying to make Kumiko’s life harder. They never pay the fee in an integer amount! The following form is what Kumiko has recorded.

Fortunately, Kumiko finds that the total sum of each month and of each member are integers. To make the table cleaner, she wants to round all data in the table into integers without changing any column or row sum. Therefore, no member is paying more in the table and the amount of money in each month keeps the same! Specifically, each fractional number can be rounded either up or down. For example, a good rounding for the data above would be as follows.

each row and column. Give an polynomial time algorithm to obtain such rounding and show the correctness of it. (Hint: (1). You can check if this kind of rounding is possible by checking whether some flow is feasible. Then show that this flow always exists. (2). You can first consider the case when *M*_{ij}* ** ∈ *[0

*1] and then generalize it.)*

*,*** **

**7 Edges that Increase Max-Flow **

**7 Edges that Increase Max-Flow**

Given a graph * G *= (

*), the source-sink pair (*

*V, E**) and capacity of edges*

*s, t*

*{*

*c*

_{e}

*0*

*≥*

*|*

*e*

*∈*

*E**, design a polynomial-time algorithm to find a set of edges*

*}**Such that for every edge*

*S.*

*e*

*∈**, increasing*

*S*

*c**will lead to an increase of max-flow value between*

*e**and*

*s**. Prove the correctness of your algorithm.*

*t*