vibster's blog

By vibster, history, 6 years ago, In English

Hey!

I was solving a problem on RMQ with the help of segment tree, but was consistently getting a SIGSEV error on submission. This was solved(gotAC) by making the size allocated for the segment tree to 6*n instead of 4*n. The segment tree implementation was a recursive one. Why did it need 6*n elements allocated since 4*n should be able to handle the worst case size.

Implementation: https://pastebin.com/usxY7ZgA Problem: https://www.spoj.com/problems/AKVQLD03/

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By vibster, history, 6 years ago, In English

Hey!

I've been stuck at this problem for the past 2 days. I came at a DP recurrence DP(i) = 1+DP(i+1)+DP(nextPossibleInterval(i)), where DP(i) represents all possible subsets of classes b/w ith and nth interval(sorted by endTime).

IMO & from what I've been able to see from solutions of other people(inTheProcessOfDebuggingMine) this logic is correct. For some reason I'm getting WA in some testCases that I'm testing myself & while submitting. I've not been able to debug my code and for that any insight into what might be going wrong is highly appreciated. Thanks!

ACCEPTED CODE, WA Code

Problem

Sample test case:

8 4 9 1 15 2 18 4 5 7 19 14 25 19 20 3 26 -1 Expected Output: 00000017; Actual Output: 00000026

Full text and comments »

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