Data Structures19 sections · 729 units
Open in Course

Polynomial Queries - Analysis

Arithmetic progression sums

For complete blocks, store two lazy values:

1.1. start[b]start[b] = the accumulated starting value for block bb

2.2. count[b]count[b] = how many polynomial updates overlap this block

For a block starting at index bStartbStart:

  • Element at index bStart+jbStart + j gets start[b]+count[b]jstart[b] + count[b] \cdot j added

Block sum contribution from lazy: Bstart[b]+count[b]B(B1)2B \cdot start[b] + count[b] \cdot \frac{B(B-1)}{2}. This formula lets you query without pushing lazy values down.