whats wrong with my logic?

Правка en1, от redsexx, 2026-03-05 15:14:20

https://codeforces.me/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.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский redsexx 2026-03-05 15:14:20 857 Initial revision (published)