File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,10 @@ This requires that we are able to compute $\log_2(R - L + 1)$ fast.
9797You can accomplish that by precomputing all logarithms:
9898
9999``` {.cpp file=sparse_table_log_table}
100- int log [MAXN+1 ];
101- log [1 ] = 0 ;
100+ int lg [MAXN+1 ];
101+ lg [1 ] = 0 ;
102102for (int i = 2 ; i <= MAXN; i++)
103- log [i] = log [i/2 ] + 1 ;
103+ lg [i] = lg [i/2 ] + 1 ;
104104```
105105
106106Afterwards we need to precompute the Sparse Table structure. This time we define $f$ with $f(x, y) = \min(x, y)$.
@@ -119,7 +119,7 @@ for (int j = 1; j <= K; j++)
119119And the minimum of a range $[ L, R] $ can be computed with:
120120
121121``` {.cpp file=sparse_table_minimum_query}
122- int j = log [R - L + 1 ];
122+ int j = lg [R - L + 1 ];
123123int minimum = min(st[L][j], st[R - (1 << j) + 1 ][j]);
124124```
125125
You can’t perform that action at this time.
0 commit comments