diff --git a/library/data_structures_[l,r)/bit.hpp b/library/data_structures_[l,r)/bit.hpp index 27162613..9b09c26e 100644 --- a/library/data_structures_[l,r)/bit.hpp +++ b/library/data_structures_[l,r)/bit.hpp @@ -20,9 +20,9 @@ struct BIT { for (; i < sz(s); i |= i + 1) s[i] += d; } ll query(int r) { - ll ret = 0; - for (; r > 0; r &= r - 1) ret += s[r - 1]; - return ret; + ll res = 0; + for (; r > 0; r &= r - 1) res += s[r - 1]; + return res; } ll query(int l, int r) { return query(r) - query(l); } #include "bit_uncommon/walk_lambda.hpp" diff --git a/library/data_structures_[l,r)/bit_uncommon/kd_bit.hpp b/library/data_structures_[l,r)/bit_uncommon/kd_bit.hpp index 45357756..2f597dfa 100644 --- a/library/data_structures_[l,r)/bit_uncommon/kd_bit.hpp +++ b/library/data_structures_[l,r)/bit_uncommon/kd_bit.hpp @@ -19,10 +19,10 @@ template struct KD_BIT { for (; i < sz(s); i |= i + 1) s[i].update(a...); } ll query(int l, int r, auto... a) { - ll ans = 0; - for (; l < r; r &= r - 1) ans += s[r - 1].query(a...); - for (; r < l; l &= l - 1) ans -= s[l - 1].query(a...); - return ans; + ll res = 0; + for (; l < r; r &= r - 1) res += s[r - 1].query(a...); + for (; r < l; l &= l - 1) res -= s[l - 1].query(a...); + return res; } }; template<> struct KD_BIT<0> { diff --git a/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp b/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp index 2ae2db99..09aff8cc 100644 --- a/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp +++ b/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp @@ -26,12 +26,12 @@ struct kth_smallest { int query(int k, int tl, int tr, int vl, int vr) { if (tr - tl == 1) return tl; int tm = tl + (tr - tl) / 2; - int left_count = pst.tree[pst.tree[vr].lch].sum - - pst.tree[pst.tree[vl].lch].sum; - if (left_count >= k) + int cnt_l = pst.tree[pst.tree[vr].lch].sum - + pst.tree[pst.tree[vl].lch].sum; + if (cnt_l >= k) return query(k, tl, tm, pst.tree[vl].lch, pst.tree[vr].lch); - return query(k - left_count, tm, tr, pst.tree[vl].rch, + return query(k - cnt_l, tm, tr, pst.tree[vl].rch, pst.tree[vr].rch); } }; diff --git a/library/data_structures_[l,r)/uncommon/deque_op.hpp b/library/data_structures_[l,r)/uncommon/deque_op.hpp index 43d17176..73a96a70 100644 --- a/library/data_structures_[l,r)/uncommon/deque_op.hpp +++ b/library/data_structures_[l,r)/uncommon/deque_op.hpp @@ -24,9 +24,9 @@ template struct deq { T front() { return (empty(l) ? r[0] : l.back())[0]; } T back() { return (empty(r) ? l[0] : r.back())[0]; } int siz() { return sz(l) + sz(r); } - void push_back(T elem) { + void push_back(T val) { r.push_back( - {elem, empty(r) ? elem : op(r.back()[1], elem)}); + {val, empty(r) ? val : op(r.back()[1], val)}); } void pop_back() { if (empty(r)) { @@ -37,9 +37,9 @@ template struct deq { } r.pop_back(); } - void push_front(T elem) { + void push_front(T val) { l.push_back( - {elem, empty(l) ? elem : op(elem, l.back()[1])}); + {val, empty(l) ? val : op(val, l.back()[1])}); } void pop_front() { if (empty(l)) { diff --git a/library/data_structures_[l,r)/uncommon/mode_query.hpp b/library/data_structures_[l,r)/uncommon/mode_query.hpp index ecef2427..1507c4e0 100644 --- a/library/data_structures_[l,r)/uncommon/mode_query.hpp +++ b/library/data_structures_[l,r)/uncommon/mode_query.hpp @@ -3,20 +3,20 @@ const int b = 318; //!< sqrt(1e5) //! https://noshi91.hatenablog.com/entry/2020/10/26/140105 struct mode_query { int n; - vi a, cnt, index_into_index; - vector index; + vi a, cnt, pos_idx; + vector pos; vector> mode_blocks; //!< {mode, cnt} of range of blocks //! @param a compressed array: 0 <= a[i] < n //! @time O(n * sqrt(n)) //! @space O(n) mode_query(const vi& a): - n(sz(a)), a(a), cnt(n), index_into_index(n), index(n), + n(sz(a)), a(a), cnt(n), pos_idx(n), pos(n), mode_blocks((n + b - 1) / b, vector((n + b - 1) / b)) { rep(i, 0, n) { - index_into_index[i] = sz(index[a[i]]); - index[a[i]].push_back(i); + pos_idx[i] = sz(pos[a[i]]); + pos[a[i]].push_back(i); } for (int start = 0; start < n; start += b) { int mode = a[start]; @@ -51,17 +51,17 @@ struct mode_query { for (int i = l / b * b + b - 1; i >= l; i--) cnt[a[i]]++; for (int i = l / b * b + b - 1; i >= l; i--) { - int idx = index_into_index[i]; - if (idx + res.second < sz(index[a[i]]) && - index[a[i]][idx + res.second] < r) + int idx = pos_idx[i]; + if (idx + res.second < sz(pos[a[i]]) && + pos[a[i]][idx + res.second] < r) res = {a[i], cnt[a[i]] + res.second}; cnt[a[i]]--; } rep(i, (r - 1) / b * b, r) cnt[a[i]]++; rep(i, (r - 1) / b * b, r) { - int idx = index_into_index[i]; + int idx = pos_idx[i]; if (idx >= res.second && - index[a[i]][idx - res.second] >= l) + pos[a[i]][idx - res.second] >= l) res = {a[i], cnt[a[i]] + res.second}; cnt[a[i]]--; } diff --git a/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp b/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp index ebf3dc30..192dac74 100644 --- a/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp +++ b/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp @@ -5,7 +5,7 @@ //! DS ds; //! // int = argument type of DS::join //! pq_updates pq(ds); -//! pq.push_update(val, priority); +//! pq.push_update(val, pri); //! pq.pop_update(); //! @endcode //! @time n interweaved calls to pop_update, push_update @@ -38,10 +38,9 @@ template struct pq_updates { extra.push_back(upd_st[idx_sk]); idx = min(idx, idx_sk), lowest_pri = pri; } - auto it = - remove_if(idx + all(upd_st), [&](auto& curr) { - return curr.second->first >= lowest_pri; - }); + auto it = remove_if(idx + all(upd_st), [&](auto& cur) { + return cur.second->first >= lowest_pri; + }); reverse_copy(all(extra), it); rep(i, idx, sz(upd_st)) ds.undo(); upd_st.pop_back(); @@ -53,13 +52,13 @@ template struct pq_updates { } } //! @param args arguments to DS::join - //! @param priority must be distinct, can be negative + //! @param pri must be distinct, can be negative //! @time O(log(n) + T(n)) //! @space an new update is allocated, inserted into //! `upd_st`, `mp` member variables - void push_update(ARGS... args, int priority) { + void push_update(ARGS... args, int pri) { ds.join(args...); - auto [it, ins] = mp.emplace(priority, sz(upd_st)); + auto [it, ins] = mp.emplace(pri, sz(upd_st)); assert(ins); upd_st.emplace_back(make_tuple(args...), it); } diff --git a/library/data_structures_[l,r]/bit.hpp b/library/data_structures_[l,r]/bit.hpp index c9f48948..754280ba 100644 --- a/library/data_structures_[l,r]/bit.hpp +++ b/library/data_structures_[l,r]/bit.hpp @@ -20,9 +20,9 @@ struct BIT { for (; i < sz(s); i |= i + 1) s[i] += d; } ll query(int i) { - ll ret = 0; - for (; i >= 0; (i &= i + 1)--) ret += s[i]; - return ret; + ll res = 0; + for (; i >= 0; (i &= i + 1)--) res += s[i]; + return res; } ll query(int l, int r) { return query(r) - query(l - 1); diff --git a/library/dsu/line_tree.hpp b/library/dsu/line_tree.hpp index 775aed30..17b64c0a 100644 --- a/library/dsu/line_tree.hpp +++ b/library/dsu/line_tree.hpp @@ -5,10 +5,10 @@ //! line_tree lt(n); //! for (auto [w, u, v] : w_eds) lt.join(u, v); //! for (int v = lt.f(0); v != -1;) { -//! auto [next, e_id] = lt.edge[v]; +//! auto [nxt, e_id] = lt.edge[v]; //! int w = w_eds[e_id][0]; //! // -//! v = next; +//! v = nxt; //! } //! @endcode //! lt.f(v) = head of linked list diff --git a/library/flow/hungarian.hpp b/library/flow/hungarian.hpp index c2f47486..3e76b777 100644 --- a/library/flow/hungarian.hpp +++ b/library/flow/hungarian.hpp @@ -18,18 +18,18 @@ pair hungarian(const vector>& cost) { p[0] = i; int j0 = 0; vector minv(m, LLONG_MAX); - vi used(m); + vi vis(m); do { - used[j0] = 1; + vis[j0] = 1; int i0 = p[j0], j1 = 0; ll delta = LLONG_MAX; - rep(j, 1, m) if (!used[j]) { + rep(j, 1, m) if (!vis[j]) { ll cur = cost[i0][j] - u[i0] - v[j]; if (cur < minv[j]) minv[j] = cur, way[j] = j0; if (minv[j] < delta) delta = minv[j], j1 = j; } rep(j, 0, m) { - if (used[j]) u[p[j]] += delta, v[j] -= delta; + if (vis[j]) u[p[j]] += delta, v[j] -= delta; else minv[j] -= delta; } j0 = j1; diff --git a/library/graphs/bcc_callback.hpp b/library/graphs/bcc_callback.hpp index 268bdd80..a9b9ec70 100644 --- a/library/graphs/bcc_callback.hpp +++ b/library/graphs/bcc_callback.hpp @@ -4,17 +4,17 @@ //! { //! vector g(n); //! DSU dsu(n); -//! vector seen(n); +//! vector vis(n); //! bcc(g, [&](const vi& nodes) { -//! int count_edges = 0; +//! int cnt_edges = 0; //! rep (i, 0, sz(nodes) - 1) { -//! seen[nodes[i]] = 1; -//! for (int u : g[nodes[i]]) if (!seen[u]) { +//! vis[nodes[i]] = 1; +//! for (int u : g[nodes[i]]) if (!vis[u]) { //! // edge nodes[i] <=> u is in current BCC -//! count_edges++; +//! cnt_edges++; //! } //! } -//! if (count_edges == 1) { +//! if (cnt_edges == 1) { //! // nodes[0] <=> nodes[1] is a bridge //! return; //! } diff --git a/library/graphs/uncommon/enumerate_triangles.hpp b/library/graphs/uncommon/enumerate_triangles.hpp index 7108a2a5..45ce8776 100644 --- a/library/graphs/uncommon/enumerate_triangles.hpp +++ b/library/graphs/uncommon/enumerate_triangles.hpp @@ -16,11 +16,11 @@ void enumerate_triangles(const vector& edges, int n, if (tie(deg[u], u) > tie(deg[v], v)) swap(u, v); g[u].push_back(v); } - vector seen(n); + vector vis(n); for (auto [u, v] : edges) { - for (int w : g[u]) seen[w] = 1; + for (int w : g[u]) vis[w] = 1; for (int w : g[v]) - if (seen[w]) f(u, v, w); - for (int w : g[u]) seen[w] = 0; + if (vis[w]) f(u, v, w); + for (int w : g[u]) vis[w] = 0; } } diff --git a/library/math/count_paths/count_paths_rectangle.hpp b/library/math/count_paths/count_paths_rectangle.hpp index de589c4f..4102f503 100644 --- a/library/math/count_paths/count_paths_rectangle.hpp +++ b/library/math/count_paths/count_paths_rectangle.hpp @@ -8,13 +8,13 @@ //! @time O((n + m)log(n + m)) //! @space O(n + m) array get_right_and_top(vl left, vl bottom) { - array ret; - for (vl& res : ret) { + array res; + for (vl& cur : res) { { vl tr(sz(left)); rep(i, 0, sz(tr)) tr[i] = C(i + sz(bottom) - 1, i); - res = conv(left, tr); - res.resize(sz(left)); + cur = conv(left, tr); + cur.resize(sz(left)); } { vl tr(sz(left) + sz(bottom)); @@ -23,13 +23,13 @@ array get_right_and_top(vl left, vl bottom) { vl dp(sz(bottom)); rep(i, 0, sz(dp)) dp[i] = bottom[i] * t[sz(dp) - 1 - i].inv_fact % mod; - vl tmp_res = conv(dp, tr); - rep(i, 0, sz(res)) - res[i] = (res[i] + tmp_res[i + sz(bottom) - 1] * + vl tmp = conv(dp, tr); + rep(i, 0, sz(cur)) + cur[i] = (cur[i] + tmp[i + sz(bottom) - 1] * t[i].inv_fact) % mod; } swap(left, bottom); } - return ret; + return res; } diff --git a/library/math/num_distinct_subsequences.hpp b/library/math/num_distinct_subsequences.hpp index fdbff729..2ff86242 100644 --- a/library/math/num_distinct_subsequences.hpp +++ b/library/math/num_distinct_subsequences.hpp @@ -7,12 +7,12 @@ int num_subsequences(const vi& a, int mod) { vector dp(sz(a) + 1, 1); map last; rep(i, 0, sz(a)) { - int& curr = dp[i + 1] = 2 * dp[i]; - if (curr >= mod) curr -= mod; + int& cur = dp[i + 1] = 2 * dp[i]; + if (cur >= mod) cur -= mod; auto it = last.find(a[i]); if (it != end(last)) { - curr -= dp[it->second]; - if (curr < 0) curr += mod; + cur -= dp[it->second]; + if (cur < 0) cur += mod; it->second = i; } else last[a[i]] = i; } diff --git a/library/strings/binary_trie.hpp b/library/strings/binary_trie.hpp index 1ab72dbc..7dad0550 100644 --- a/library/strings/binary_trie.hpp +++ b/library/strings/binary_trie.hpp @@ -10,7 +10,7 @@ const ll mx_bit = 1LL << 60; struct binary_trie { struct node { int siz = 0; - array next = {-1, -1}; + array nxt = {-1, -1}; }; deque t; binary_trie(): t(1) {} @@ -18,11 +18,11 @@ struct binary_trie { int v = 0; for (ll bit = mx_bit; bit; bit /= 2) { bool b = num & bit; - if (t[v].next[b] == -1) { - t[v].next[b] = sz(t); + if (t[v].nxt[b] == -1) { + t[v].nxt[b] = sz(t); t.emplace_back(); } - v = t[v].next[b]; + v = t[v].nxt[b]; t[v].siz += delta; } } @@ -31,9 +31,9 @@ struct binary_trie { ll res = 0; for (ll bit = mx_bit; bit; bit /= 2) { bool b = num & bit; - int u = t[v].next[b]; + int u = t[v].nxt[b]; if (u != -1 && t[u].siz > 0) v = u, res |= num & bit; - else v = t[v].next[!b], res |= (~num) & bit; + else v = t[v].nxt[!b], res |= (~num) & bit; } return res; } diff --git a/library/strings/trie.hpp b/library/strings/trie.hpp index 9ed0ecfd..e638a1ca 100644 --- a/library/strings/trie.hpp +++ b/library/strings/trie.hpp @@ -3,9 +3,9 @@ const int mn = 'A'; struct trie { struct node { - array next; + array nxt; bool end_of_word = 0; - node() { ranges::fill(next, -1); } + node() { ranges::fill(nxt, -1); } }; deque t; trie(): t(1) {} @@ -13,11 +13,11 @@ struct trie { int v = 0; for (char ch : s) { int u = ch - mn; - if (t[v].next[u] == -1) { - t[v].next[u] = sz(t); + if (t[v].nxt[u] == -1) { + t[v].nxt[u] = sz(t); t.emplace_back(); } - v = t[v].next[u]; + v = t[v].nxt[u]; } t[v].end_of_word = 1; } @@ -25,8 +25,8 @@ struct trie { int v = 0; for (char ch : s) { int u = ch - mn; - if (t[v].next[u] == -1) return 0; - v = t[v].next[u]; + if (t[v].nxt[u] == -1) return 0; + v = t[v].nxt[u]; } return t[v].end_of_word; } diff --git a/tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp b/tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp index cb7a0570..c6800115 100644 --- a/tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp @@ -18,11 +18,10 @@ int main() { int type, x; cin >> type >> x; if (type == 0) { - if ( - bt.t[bt.t[0].next[0]].siz == 0 || bt.walk(x) != x) + if (bt.t[bt.t[0].nxt[0]].siz == 0 || bt.walk(x) != x) bt.update(x, 1); } else if (type == 1) { - if (bt.t[bt.t[0].next[0]].siz > 0 && bt.walk(x) == x) + if (bt.t[bt.t[0].nxt[0]].siz > 0 && bt.walk(x) == x) bt.update(x, -1); } else { assert(type == 2);