diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2025-01-18 03:05:17 +0100 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2025-01-18 03:08:45 +0100 |
| commit | 52ba871e0de9399f77da4b5b0d2c33a2dd6eb6a1 (patch) | |
| tree | 493152c57313f651cae92f88b6f24af2ede1b6d6 /test/other/sos.cpp | |
| parent | 69c98b39106cc2776f6a4983e548338ac24b5e84 (diff) | |
changes to bitwise convolutions
- modify or/and transform to remove unnecessary reversal
- or transform is now sum over subsets, add note about this
- remove old sum over subsets DP
Diffstat (limited to 'test/other/sos.cpp')
| -rw-r--r-- | test/other/sos.cpp | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/test/other/sos.cpp b/test/other/sos.cpp deleted file mode 100644 index 3ab34ea..0000000 --- a/test/other/sos.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "../util.h" - -vector<ll> sos(const vector<ll>& in) { - #include <other/sos.cpp> - return res; -} - -vector<ll> naive(const vector<ll>& in) { - vector<ll> res(ssize(in)); - for (ll i = 0; i < ssize(in); i++) { - for (ll j = 0; j <= i; j++) { - if ((i | j) == i) { - res[i] += in[j]; - } - } - } - return res; -} - -void stress_test() { - ll tests = 0; - for (ll i = 0; i < 1000; i++) { - int n = Random::integer<int>(1, 100); - auto in = Random::integers<ll>(n, -1000, 1000); - auto got = sos(in); - auto expected = naive(in); - if (got != expected) cerr << "error: " << i << FAIL; - tests += n; - } - cerr << "tested random queries: " << tests << endl; -} - -constexpr int N = 10'000'000; -void performance_test() { - timer t; - auto in = Random::integers<ll>(N, -1000, 1000); - t.start(); - auto res = sos(in); - t.stop(); - hash_t hash = 0; - for (ll x : res) hash += x; - if (t.time > 500) cerr << "too slow: " << t.time << FAIL; - cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; -} - -int main() { - stress_test(); - performance_test(); -} - |
