Sgu 210 ~ 219

Source: Internet
Author: User

Click the title to view the code

210. beloved sons

The King wants to arrange a wedding for the princes. Every prince has a weight of AI. The goal is to make the weights of all the princes who marry the beloved girl.2 normMaximum.

Match the two-point graph. Because of the greedy nature of the Hungary algorithm, the prince in front will first find a spouse. In this way, if there is a prince in the back, it must be in conflict with the prince in front, however, if modified, the answer will not be better.

211. Strange counter

A counter is given as follows:

A [N-1] * 2 ^ (N-1) + A [N-2] * 2 ^ (N-2) +... + A [1] * 2 ^ (1) + A [0]

 

The element of a [] can only be 0, 1, 2

Add M operations for you. Each operation adds 2 ^ X to the counter, and the number of a [] modified by each operation cannot exceed 4.

Output The Modification Scheme for each add operation.

Construct the question, so it is powerless .. For more information, see the description of watashi ..

212. Data Transmission

Give a layered graph and find a blocked stream. Click 1500 and the side is 300000.

Dinic = TLE, greedy_dinic = AC + slower, hlpp = ac

Templates.

213. Strong defense

A directed graph needs to dye some edges to make the most colors available. Any path from S to T contains all colors.

First, we can build a scheme that will dye the color Ci of the same layer I on the shortest path tree, if Di is not colored on the shortest path tree, any path S-> T contains at least one edge of each layer.

214. Weird dissimilarity

Question: Get two strings so that the above strings are the self-sequences of the strings, with the minimum distance.

Sbdp

215

Poor questions...

216. Royal Federation

Question: scoi royal alliance

DFS block structure. For Subtrees with a cumulative distribution less than B, for Subtrees with more than 3 * B recursive processing, other Subtrees are directly assigned.

217. Two Cylinders

Brute force credits.

218. Unstable Systems

SB question. Bipartite + Bipartite Graph Matching

219. synchrograph

Question:

In systems, a special case of Petri nets is often taken into account, which is called synchrograph. Synchrograph is a directed graph. Each arc has a non-negative integer weight.
A vertex. If all edges pointing to it are positive numbers (that is, greater than 0), This vertex is called a "consumable vertex ".
Synchrograph operations are performed in one round. In each round, the operator selects a "consumable point" randomly for "Burning ".
The so-called combustion is: all the arc weights pointing to this point are reduced by 1, and all the arcs from this point are added by 1. After each round, the "consumable point" is updated based on the new arc weight, and the next round is continued.
If an operation sequence changes a vertex to a consumable vertex, This vertex is called a "potential active vertex ". If a point is still a "potential activity point" after any operation sequence, this point is called "activity point ".

Input
The first line contains two integers, N and M, indicating the number of vertices and the number of arcs (1 <= n <= 1000, 1 <= m <= 50000 ). Next, each row in the M line describes an edge. Each line contains three numbers, indicating the start point, end point, and right of an arc. All permissions cannot exceed 109.

Output
The output contains N rows, and the I th row describes the I th vertex. If it is an active point, 1 is output; otherwise, 0 is output.

Sample test (s)

Input

6 8
1 2 1
4 3 0
2 4 0
4 3 1
1 6 0
6 3 1
3 2 0
4 5 1000000000

Output
1
0
0
0
0
1

The above is the translation of Mr. He Lin.

We can know that if a vertex is not an activity vertex, his successor will not be an activity vertex because the edge weight can be consumed cleanly and not supplemented. If there is a zero ring, then the points in the ring must be inmovable points, because external changes cannot enter the ring. As shown above, the problem becomes zero-ring, and the SCC is directly mounted. A topological sorting method is also used.

Sgu 210 ~ 219

Related Keywords:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.