We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5eef2d6 commit 196f126Copy full SHA for 196f126
library/data_structures/uncommon/mode_query.hpp
@@ -4,7 +4,7 @@ const int b = 318; //!< sqrt(1e5)
4
struct mode_query {
5
int n;
6
vi a, cnt, index_into_index;
7
- vector<vi> index;
+ vector<basic_string<int>> index;
8
vector<vector<pii>>
9
mode_blocks; //!< {mode, cnt} of range of blocks
10
//! @param a compressed array: 0 <= a[i] < n
@@ -16,7 +16,7 @@ struct mode_query {
16
vector<pii>((n + b - 1) / b)) {
17
rep(i, 0, n) {
18
index_into_index[i] = sz(index[a[i]]);
19
- index[a[i]].push_back(i);
+ index[a[i]] += i;
20
}
21
for (int start = 0; start < n; start += b) {
22
int mode = a[start];
0 commit comments