ganmodokix / ysn

Template tools for competitive programming
Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Template: Lazy-Fill Array #58

Open ganmodokix opened 2 months ago

ganmodokix commented 2 months ago

Summary

Add Lazy Fill Array as follows:

Implementation

A lazy fill array has a extra fill value, an extra counter and an extra array to hold the counter value when each array element has last modified. Once update-all query comes up, the counter is incremented. Then, you can use counter_value == last_modified[i] to find whether each element value is still valid.