Array Restoration getting WA even after using sparse table

1023
array-restoration
codeforces
div2
range-queries
sparse-tables

#1

I am trying to solve Array Restoration on codeforces for such a long time and I am getting WA on 6th test. I used sparse table for finding the minimum of the range in O(1) and it took O(nlogn) for preprocessing the sparse table. I don’t know why I am getting WA at it. Please anyone help me…

Question Link

Submission link

This is my 10th submission by the way…