Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are playing a cop and a thief. The police team wins by catching the thief before he reaches the starting point. There are a

image text in transcribedimage text in transcribed You are playing a cop and a thief. The police team wins by catching the thief before he reaches the starting point. There are a total of n bases, and the start and end points are included in the bases. The thief's path of travel can be through the bases and the paths between them. The police team has developed a strategy to ensure the thief's capture. The strategy is to place personnel on certain roads so that the thief must pass through the roads where the police are stationed in order to reach the endpoint. However, depending on the width of each road, a certain number of people must be deployed to block the road. Write a program that outputs the total number of officers that would be deployed if the minimum number of officers were deployed according to the strategy. Conditions The starting point has node number 0 and the ending point has node number n1. All roads are one-way. There are 0 to 2 roads between any two nodes. There is no direct path from the start point to the end point. There is no way to get from the start point to the end point. Input Format On the first line, the number of nodes, n, and the number of roads, m, are given, separated by spaces. ( 3n100,2m2,000,n,m are integers) From line 2 to line m+1, the information of the roads is given, separated by spaces. The road information consists of three integers: the starting point ai of the two bases connected by the road, the ending point bj, and the minimum number of police officers ci that should be deployed on the road. (1ci100,000, where ci is an integer ) Output Format Output the total number of police officers deployed, given the minimum number of police officers. Write in Python, and use Min-Cut Max-Flow Theorem. Timeout per a testcase 0.43s. therefore measuring time is necessary. Include it in the code. Important) I would be very grateful if you could include a screenshot of the sample output when you put in the sample input

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

ISBN: 1951077083, 978-1951077082

More Books

Students also viewed these Databases questions