Master0fPuppets's blog

By Master0fPuppets, history, 2 months ago, In English

in this problem I used sparse table to get the max number in the interval from l+1 to r-1 inclusive, however, I get an error which is segmentation fault and I can't find the cause of the problem.

problem: https://www.spoj.com/problems/THRBL/

code: https://ideone.com/HBFP8t

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

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Any help :(

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

maybe because if r=l+1, then length =(r-1)-(l+1) +1= -1, so that causes a segmentation fault for your log array.