eolymp
bolt
Try our new interface for solving problems
Problems

Maximum forest cover digraph

Maximum forest cover digraph

Set-oriented weighted graph. Required to cover its set of outgoing total maximum value of the trees that are disjoint from the top. \InputFile The input file consists of one or more sets of input data. Each set begins with a line containing two integers \textbf{n} and \textbf{m} (\textbf{1} ≤ \textbf{n} ≤ \textbf{200}, \textbf{0} ≤ \textbf{m} ≤ \textbf{10000}). \textbf{n} - number of vertices and \textbf{m} - the number of edges. Next is the \textbf{m} lines, each of which contains three numbers \textbf{x_i}, \textbf{y_i}, \textbf{c_i} - start vertex, end vertex and the weight of the arc. Digraph has no loops, but may contain multiple arcs. The total number of edges over all sets of input data of one test does not exceed \textbf{10000}. \OutputFile For each set of input output three lines. The first of these output weights of optimal covering the trees, the second - the number of arcs in the coating, the third - numbers selected to cover edges. Bring a blank line after each block of output data.
Time limit 1 second
Memory limit 256 MiB
Input example #1
6 8
6 1 7
5 6 2
3 6 5
1 2 5
4 5 4
3 4 6
3 1 8
6 3 1
6 8
4 5 1
6 2 4
6 1 6
2 3 7
3 2 7
1 6 8
2 5 6
5 1 4
Output example #1
28
5
3 4 5 6 7 

25
4
2 4 6 7