|
tgen
|
Worst-case generation for specific problems. More...
Functions | |
| std::string | tgen::hack::abacaba (int n) |
| Returns the prefix of the infinite word "abacabad...". | |
| std::pair< std::string, std::string > | tgen::hack::unsigned_polynomial_hash_hack () |
| Returns two strings that force polynomial hash collision for power-of-two mod. | |
| std::pair< std::string, std::string > | tgen::hack::polynomial_hash_hack (int alphabet_size, int base, int mod) |
| Returns two strings that force polynomial hash collision given base and mod. | |
| std::pair< std::string, std::string > | tgen::hack::polynomial_hash_hack (int alphabet_size, std::vector< int > bases, std::vector< int > mods) |
| Returns two strings that force polynomial hash collision given bases and mods. | |
| std::vector< long long > | tgen::hack::std_unordered (int size) |
| List of integers that tries to force collision on std::unordered_set. | |
| std::vector< std::pair< int, int > > | tgen::hack::mo (int n, int q) |
| Query list that tries to force asymptotic worst-case for Mo's algorithm. | |
| std::vector< std::string > | tgen::hack::string_set (int size) |
| List of strings that have high cost to insert in a std::set. | |
Worst-case generation for specific problems.
|
inline |
Returns the prefix of the infinite word "abacabad...".
| n | Length of the prefix. |
O(n).
|
inline |
Query list that tries to force asymptotic worst-case for Mo's algorithm.
| n | Size of the array operated upon. |
| q | Number of queries to be returned. |
The expected number of pointer moves are as follows, assuming standard implementations:
O(n log n).
|
inline |
Returns two strings that force polynomial hash collision given base and mod.
| alphabet_size | Alphabet size. |
| base | Base. |
| mod | Mod. |
Computes two strings that have the same polynomial hash for given base and mod.
Characters are in [a, a + alphabet_size). The larger the alphabet, the smaller the colided strings.
Reference:
O(sqrt(mod) log mod).
|
inline |
Returns two strings that force polynomial hash collision given bases and mods.
| alphabet_size | Alphabet size. |
| bases | Bases. |
| mods | Mods. |
Computes two strings that have the same polynomial hash for given bases and mods, up to 2 (base, mod) pairs.
Characters are in [a, a + alphabet_size). The larger the alphabet, the smaller the colided strings.
Reference:
O(sqrt(mod) log^2 mod), with mod = max(mods).
|
inline |
List of integers that tries to force collision on std::unordered_set.
| size | Size of the list. |
Creates hack for both std::unordered_set and std::unordered_map, forcing quadratic behavior. The hack might not be effective due to differences in C++ implementations.
O(size).
|
inline |
List of strings that have high cost to insert in a std::set.
| size | Size of the list. |
Inserting these strings in a std::set takes Theta(size log(size)) time, and that is asymptotically the maximum one can achieve.
O(size log(size)).
|
inline |
Returns two strings that force polynomial hash collision for power-of-two mod.
Computes two strings that have the same polynomial hash for any base and power-of-two mod (up to 2^64).
Characters are in [a, b].
Reference:
O(1).