1

Any language is fine. I'm trying to determine if this is possible.

Suppose there are N nodes that need to be connected together. There should exist a path between every pair of nodes. x creates i connections, and y creates j connections.

The bias = |i-j|

I am trying to figure out the smallest achievable bias, given a set of possible connections from each (x and y).

Input Format:

Line 1: l k There exists l nodes labeled 1 through l, and there are k connections

Next k lines: z x v Each line indicates a connection where z and x are nodes, and c is either "x" or "y", the builder of the connection. The set of connections will always be enough to yield at least one valid set of connections.

Here is an example of the input:

4 4
1 2 x
2 3 y
3 4 x
4 1 y

The output of this is 1

ZisIzHell
  • 140
  • 7

0 Answers0