STICNOT - Sticky notes solution?

I thought exactly the same way and was lost trying DP on graphs. I could not contemplate the question such that it allows us to alter the structure!

Yeah, it sucks really. Do you think the fault is on our part though for not having interpreted correctly? I honestly feel like the question isn’t clear enough in defining what swapping of 2 edges means.

I don’t know exactly. On the top of it ,it was the second least solved problem which made such assumption non-trivial. Anyways what’s done is done!

With a somewhat similar idea, my submission bags TLE on the last two testcases, could you help as to why?
My Submission

Cool! This one’s way more elegant than mine.
I’m surprised such an easy answer was even possible but it makes sense.

1 Like

Okay see it like this: if you have a tree defined by a set of vertices and edges, how do you know which edge is which? Well, you may like to label them (like saying, for example, e1, e2, …) when the edge weights are uniform (or all equal) and it doesn’t pay to use a similar convention when we have different edge weights assigned to different edges/labels. So every edge has an identity, by which we can recognize (or simply identify it from every other in the tree). Likewise, say we assigned the vertices a set of labels to identify them. Now, what happens when swapping is allowed?

We swap edge weights among edges and node weights among vertices, and these two kinds of swaps would make you visualize that even if you fix the labels, the numbers (weights) within those labels are moving all around the tree (and that would give rise to all kinds of edge weight - node weight associations). The reason the structure is trivial is this: the constraints are on the edge weight - node weight associations and is it constant or varying to our will? Since we can change the associations with swaps which are not costing us anything, why won’t we (if that eventually minimizes what we actually may pay)? Because we are so lost in permuting the association and satisfying the constraints at every edge across the tree, we no longer care for the identities of the poor edges and nodes as long as we have a tree in the end. Hence, for the sake of visualization you can imagine the tree’s structure as complicated as you may or as simple as you may (like a line) :slightly_smiling_face:

For reference, a solution and the corresponding submission link is posted above that builds on this observation.
1 Like

the question said you could swap the values. Didn’t mention anything about whether you can change the structure or not!

1 Like

Does we don’t have to care for the degree of each vertex?

Nope, not really; although proving it might be difficult

1 Like