3 ms·
At first glance, how I'd find the maximum: 1. Reorient the cells from paralellograms to squares, with integer coordinates. 2. Create lookup tables, with dots
by pronoiac 15y ago
At first glance, how I'd find the maximum:
1. Reorient the cells from paralellograms to squares, with integer coordinates.
2. Create lookup tables, with dots from the origin to a given (x, y).
3. Any given rectangle:
A B
C D
has a count given by the lookup tables for B and C, minus A and D.
4. Then, iterate over all the rectangles.
I guess with a set this sparse, you could numerate all the useful x and y to check, and skip step 1.
Edit: I chose the bottom left as the origin, incidentally.