https://mirror.codeforces.com/contest/2171/submission/365464004
My idea is simple. Divide the array into maximal strictly increasing subarrays.
Inside each subarray, connect adjacent elements with undirected edges.
For every subarray i starting from the second one, connect the last element of that subarray to the minimum element that appeared before it (I maintain a running minimum from previous parts).
After building the graph, I run DFS to check if the graph becomes connected.
If it is connected, I print "yes" and output the tree.
My code builds the graph exactly like this, but it gives wrong answers on some test.
So I want to know:
Is the logic itself incorrect, or is there likely an implementation mistake?
If the logic is wrong, where exactly does this idea fail?
Any hints would help.



