Planar Max Cut
Time limit7sMemory limit512 MB
Given a planar graph with a fixed straight-line embedding and edge costs, split the vertices into two sets so the total cost of edges crossing between them is maximized.
- Level
Hard8 of 10
- Topics
- Graph, Dynamic programming, Divide and conquer
- Solved
- No attempts yet
Problem
Some of you may know how to find a minimum cut in a graph. Some of you may also know that the maximum cut problem is NP-complete (more precisely, the decision version of finding a cut of value at least is NP-complete). For some restricted classes of graphs, however, the problem is easier than in the general case.
Consider the Planar Maximum Cut problem. You are given an undirected graph with vertices and edges, where . The graph is planar, and its embedding is given: the coordinates of every vertex are known, and when the edges are drawn as segments, no two edges share an internal point. Edge has an integer cost .
Partition the vertices into two disjoint sets and () so that the total cost of the cut edges is maximized. An edge is a cut edge if one of its endpoints is in and the other is in .
Input
The first line contains two integers and (, ).
Each of the next lines contains two integers and (), the coordinates of vertex . No two points coincide.
Each of the next lines contains three integers , , and (, , ). This means edge connects vertices and and has cost .
Output
Print the maximum total cost of the cut edges on the first line.
On the second line, print integers . Print if vertex is in , and if vertex is in . If several answers exist, print any of them.