I've encountered some interesting problems but I couldn't solve them. I really need some help.
First problem is: Given 3 integers N, M, X (1 <= N, M <= 105, 1 <= X <= m). Calculate the number of ways to create n segments [L1, R1], [L2, R2], …, [Ln, Rn] (Li <= Hi) such that they satisfy two conditions:
- there is no i and k (i != k) that Li <= Lk <= Hk <= Hi
- There is at least one segment which has Li = s