#include "../util.h" #include struct Seg { // very real segment tree vector a; Seg(int n) : a(n) {} void inc(int l, int r) { for (int i=l; i(1, 50); Graph g(n); g.tree(); adj.assign(n, {}); g.forEdges([&](int a, int b){ adj[a].push_back(b); adj[b].push_back(a); }); init(Random::integer(0, n)); vector a(n); auto dfs = [&](auto& self, int u, int p, int t) { if (u == t) { a[u]++; return true; } for (int v : adj[u]) if (v != p) { if (self(self, v, u, t)) { a[u]++; return true; } } return false; }; Seg seg(n); int Q = Random::integer(1, 50); for (int q=0; q g(N); g.tree(); adj.assign(N, {}); g.forEdges([&](int a, int b){ adj[a].push_back(b); adj[b].push_back(a); }); vector> qu(N); for (auto& [x, y] : qu) x = Random::integer(0, N), y = Random::integer(0, N); ll hash = 0; t.start(); init(0); for (auto [x, y] : qu) for_intervals(x, y, [&](int l, int r){ hash += r-l; }); t.stop(); if (t.time > 1000) cerr << "too slow: " << t.time << FAIL; cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; } int main() { stress_test(); performance_test(); }