diff options
author | Ta180m | 2019-08-02 22:03:09 -0500 |
---|---|---|
committer | GitHub | 2019-08-02 22:03:09 -0500 |
commit | 2ffa010d792d5bdc08ced5d76b3482206ef4b19e (patch) | |
tree | f539bb4c714f111397bd634b90c33de2c330c79c /Data Structures | |
parent | 5eade53a767f76e6ab6f9667255576ab0f18046b (diff) |
Update sparse_table.cpp
Diffstat (limited to 'Data Structures')
-rw-r--r-- | Data Structures/sparse_table.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Data Structures/sparse_table.cpp b/Data Structures/sparse_table.cpp index 88fbf86..c303930 100644 --- a/Data Structures/sparse_table.cpp +++ b/Data Structures/sparse_table.cpp @@ -6,9 +6,9 @@ public: sparse_table(vector<T> &A) { int N = A.size(); for (int i = 0; i <= log(N); i++) st[i].resize(N); - for (int i = 0; i < N; i++) st[i][0] = A[i]; - for (int i = 0; i <= log(N); i++) { - for (int j = 1; j + (1 << i) < N; j++) st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]); + for (int i = 0; i < N; i++) st[0][i] = A[i]; + for (int i = 1; i <= log(N); i++) { + for (int j = 0; j + (1 << i) < N; j++) st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]); } } |