SAT2020's blog

By SAT2020, history, 23 months ago, In English

Hello Codeforces!

After Tuesday's contest, I decided to learn a little bit more about Sparse Tables. While solving this problem on Codechef, I came across some code that has been heavily confusing me for the past few hours. Basically, when I initialize the sparse table "table" as an array, everything works great. But when I initialize it as a 4-D vector inside the function "build_table", the code gives segmentation fault on large test cases! I've attached both submissions below. Any help would be extremely appreciated!

Submission 1 (Array, AC)

Submission 2 (Vector, Seg Fault)

Thanks! -Simon

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