My Logic:
- First i compress the coordinates.
- Then when updating i use the fake coordinates i.e compressed coordinates as indexes for the BIT but for performing the calculation of updates i use the original coordinates by extracting original from fakes using the reverse map rm<int,int>.
- I store the bomb values using fake indexes. and when calculating i use the fake index to get the bombs;
- Also when i update i first check whther at that fake index when converted to original index by reverse map rm, is there actually any soldier present? I yes only then i update the BIT at that fake index.
- On querying i just get the sum from 0 to n in BIT.
Is My approach Wrong:?
Plz provide code if possible or just give the logic.