Hello,
Maybe someone has solved this problem. I tried to solve it but everything was in vain. I think that we have a disconnected graph and we just need to count degrees of every vertex in connected components. Then we know what minimum number of threads is needed. But how to create a graph from the given images? One very intuitive approach would be this. Where red edges are stitches on the face of cloth and green edges are stitches on the rear of cloth. The graph itself represents the sample input. How to change this graph that the problem could be solved? I think that we need to make its edges of the same type. But how to do it?
I get WA #9 with this. Why doesn't it work? What is the correct approach?