|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Policy: "powerful array" sum = sum(cnt[x]^2 * x). More...
#include <tpl_mo_algorithm.H>
Public Types | |
| using | answer_type = long long |
Public Member Functions | |
| void | init (const Array< T > &, size_t) |
| void | add (const Array< T > &data, size_t idx) |
| void | remove (const Array< T > &data, size_t idx) |
| answer_type | answer () const |
Public Attributes | |
| MapOLhash< T, long long > | cnt |
| long long | sum = 0 |
Policy: "powerful array" sum = sum(cnt[x]^2 * x).
For each element x in the current window with count c, the contribution is c^2 * x. We maintain the sum incrementally: add x: sum += (2*cnt+1)*x, then cnt++ remove x: cnt–, then sum -= (2*cnt+1)*x
| T | Element type (must be hashable and arithmetic-like). |
Definition at line 453 of file tpl_mo_algorithm.H.
| using Aleph::Powerful_Array_Policy< T >::answer_type = long long |
Definition at line 455 of file tpl_mo_algorithm.H.
|
inline |
Definition at line 467 of file tpl_mo_algorithm.H.
References Aleph::Powerful_Array_Policy< T >::cnt, and Aleph::Powerful_Array_Policy< T >::sum.
|
inline |
Definition at line 481 of file tpl_mo_algorithm.H.
References Aleph::Powerful_Array_Policy< T >::sum.
|
inline |
Definition at line 460 of file tpl_mo_algorithm.H.
References Aleph::Powerful_Array_Policy< T >::cnt, and Aleph::Powerful_Array_Policy< T >::sum.
|
inline |
Definition at line 474 of file tpl_mo_algorithm.H.
References Aleph::Powerful_Array_Policy< T >::cnt, and Aleph::Powerful_Array_Policy< T >::sum.
| MapOLhash<T, long long> Aleph::Powerful_Array_Policy< T >::cnt |
Definition at line 457 of file tpl_mo_algorithm.H.
Referenced by Aleph::Powerful_Array_Policy< T >::add(), Aleph::Powerful_Array_Policy< T >::init(), and Aleph::Powerful_Array_Policy< T >::remove().
| long long Aleph::Powerful_Array_Policy< T >::sum = 0 |
Definition at line 458 of file tpl_mo_algorithm.H.
Referenced by Aleph::Powerful_Array_Policy< T >::add(), Aleph::Powerful_Array_Policy< T >::answer(), Aleph::Powerful_Array_Policy< T >::init(), and Aleph::Powerful_Array_Policy< T >::remove().