ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1670. Asterisk

How do you solve this problem?
Posted by Alex Tolstov (Vologda STU) 18 Nov 2009 16:51
Re: How do you solve this problem?
Posted by 👨‍💻Stepavly👨‍💻 [ITMO] 23 Jul 2020 04:12
Let's construct the resulting sequence from N to 1 by keeping merged segments in stack. What is the condition for merging two segments? They are touching by one of the sides (r_1+1=l_2 or r_2+1=l_1). The last part of the solution is trivial (make a tree of merges, ...).