biranchi's blog

By biranchi, history, 4 years ago, In English

Hello, codeforces I was doing D of ACL contest 2 today. Before diving into the issue I want to specify that I know the basic use of segment tree, like finding max range query and update. It seemed to me similar with LIS. After scratching some time, I came up with segment tree idea. Here I am writing about my idea.

  1. taking x as input
  2. Finding the maximum range query of x-k to x+k i.e. maxh
  3. updating the index of x with the value of maxh+1.
  4. Atlast finding maximum range query from 1 to n

I am pretty sure that this method should solve this problem but in the contest, submission gave 6 correct and 26 wrong results. I want to know your feedback and suggestions.

I copied the code of the segment tree from gfg and modified as per the requirements. Here is my code link Here is problem link

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
Rev. 2   Vote: I like it +2 Vote: I do not like it

You're taking ranges of segtree as 1 to n where n is the length of the array. Range of segtree should be upto 3e5(max array element possible). Link to my submission.

»
3 years ago, # |
  Vote: I like it +3 Vote: I do not like it

size of segment tree is incorrect