Need help in problem 279C (Ladders)

Revision en1, by kipawa, 2015-06-28 12:37:30

I was solving problem 279C (Ladders)
My logic is to create two arrays inc and dec
inc[i] contains the largest j, such that i<=j and the sequence from ai, ai+1, ..., aj is increasing.
dec[i] contains minimum j, such that i>=j and the sequence from aj, aj+1, ..., ai is decreasing.
Now the sequence l,r is ladder if inc[l-1]==dec[r-1] || inc[l-1]>=r-1 || dec[r-1]<=l-1 (I used 0 based indexing)
I am getting WA on test 20, please help me!
Solution Link
Thanks in advance!

Tags help, 279c, wrong answer

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English kipawa 2015-06-28 12:37:30 736 Initial revision (published)