Minimums on the Edges
Time limit4sMemory limit512 MB
Given a graph with up to 18 vertices and s tokens, place the tokens on vertices to maximize the sum of min(a_u, a_v) over all edges, and print the counts.
- Level
Hard8 of 10
- Topics
- Brute force, Bit manipulation, Graph
- Solved
- No attempts yet
Statement
You are given an undirected graph with vertices and edges. Each vertex can hold several tokens. Initially, no vertex has any tokens, but you have tokens that you can distribute among the vertices.
The capacity of each edge is the smaller of the numbers of tokens on its two endpoints. Your goal is to maximize the sum of the capacities of all edges.
Input
The first line contains three integers , , and : the number of vertices, the number of edges, and the number of tokens to distribute (, , ).
Each of the next lines describes one edge with two integers and , the indices of the vertices it connects ().
The graph has no self-loops. However, there can be multiple edges between the same pair of vertices.
Output
Print numbers (), where is the number of tokens on vertex . The printed numbers must sum to . The sum of the capacities of all edges must be as large as possible.
If several optimal answers exist, print any of them.
Hint
In the first sample, the sum of capacities is .
In the second sample, the sum of capacities is .