diff --git a/code/data-structures/persistent-treap/main.cpp b/code/data-structures/persistent-treap/main.cpp index febd13d..1b6612b 100644 --- a/code/data-structures/persistent-treap/main.cpp +++ b/code/data-structures/persistent-treap/main.cpp @@ -4,6 +4,7 @@ * \texttt{insert(i, val)} insertuję na pozycję $i$, * kopiowanie struktury działa w O(1), * robimy sobie \texttt{vector} żeby obsługiwać trwałość + * UPD. uwaga potencjalnie się kwadraci, spytać Bartka kiedy */ mt19937 rng_i(0); struct Treap { diff --git a/code/graph/hld/main.cpp b/code/graph/hld/main.cpp index 58331ca..cb5ed10 100644 --- a/code/graph/hld/main.cpp +++ b/code/graph/hld/main.cpp @@ -7,7 +7,7 @@ * \texttt{get\_subtree(v)} zwraca przedział preorderów odpowiadający podrzewu v. */ struct HLD { - // BEGIN HASH +// BEGIN HASH vector> &adj; vector sz, pre, pos, nxt, par; int t = 0; diff --git a/code/main.tex b/code/main.tex index b34568f..f1e4c65 100644 --- a/code/main.tex +++ b/code/main.tex @@ -10,9 +10,9 @@ \usepackage[fontsize=9pt]{fontsize} \kactlcontentdir{code} -\university{\textsf{University of Warsaw, Warsaw Eagles 2023}}{\textsf{University of Warsaw}}{uw} -\team{\textsf{Warsaw Eagles 2023}}{\textsf{Tomasz Nowak, Arkadiusz Czarkowski, Bartłomiej Czarkowski}} -\contest{\textsf{ICPC World Finals 2023}}{\textsf{\today}} +\university{\textsf{University of Warsaw, Warsaw Eagles 2024}}{\textsf{University of Warsaw}}{uw} +\team{\textsf{Warsaw Eagles 2024}}{\textsf{Tomasz Nowak, Arkadiusz Czarkowski, Bartłomiej Czarkowski}} +\contest{\textsf{ICPC World Finals 2024}}{\textsf{\today}} % \enablecolors \usepackage{fontspec} diff --git a/code/math/useful.tex b/code/math/useful.tex index c0dc605..785899e 100644 --- a/code/math/useful.tex +++ b/code/math/useful.tex @@ -195,3 +195,11 @@ \section{Zasada włączeń i wyłączeń} W szczególności $S_0 = |X|$. Niech $D(k)$ oznacza liczbę elementów $X$ mających dokładnie $k$ własności. $D(k) = \sum_{j\ge k}\binom{j}{k} \left(-1\right)^{j-k}S_j$ W szczególności $D(0) = \sum_{j \ge 0} \left(-1\right)^j S_j$ + +\section{Karp’s minimum mean-weight cycle algorithm} +$G = (V, E)$ - directed graph with weight function $w : E \to \mathbb{R}$ +$n = |V|$ +Assume that every vertex is reachable from $s \in V$. +$\delta_k(s, v)$ shortest $k$-path from $s$ to $v$ (simple dp) +Minimum mean-weight cycle is +$$ \min_{v\in V} \max_{0 \leq k \leq n-1} \frac{\delta_n(s, v) - \delta_k(s, v)}{n - k} $$ diff --git a/code/optimizations/chapter.tex b/code/optimizations/chapter.tex index a4821a5..7eadfad 100644 --- a/code/optimizations/chapter.tex +++ b/code/optimizations/chapter.tex @@ -5,6 +5,7 @@ \chapter{Optymalizacje} \myimport{fio} \myimport{knuth} \myimport{linear-knapsack} +\myimport{matroid-intersection} \myimport{pragmy} \myimport{random} \myimport{sos-dp} diff --git a/code/optimizations/matroid-intersection/main.cpp b/code/optimizations/matroid-intersection/main.cpp index 43c4911..f36fd4b 100644 --- a/code/optimizations/matroid-intersection/main.cpp +++ b/code/optimizations/matroid-intersection/main.cpp @@ -1,13 +1,14 @@ /* - * Opis: Find largest subset S of [n] such that S is independent in both + * Opis: O(r^2 \cdot (init + n \cdot add)), where r is max independent set. + * Find largest subset S of [n] such that S is independent in both * matroid A and B, given by their oracles, see example implementations below. * Returns vector V such that V[i] = 1 iff i-th element is included in found set; - * Time: O(r^2 \cdot (init + n \cdot add)), where r is max independent set. * Zabrane z https://github.com/KacperTopolski/kactl/tree/main * Zmienne w matroidach ustawiamy ręcznie aby "zainicjalizować" tylko jeśli mają * komentarz co znaczą. W przeciwnym wypadku intersectMatroids zrobi robotę wołając init. */ +// BEGIN HASH template vector intersectMatroids(T& A, U& B, int n) { vector ans(n); @@ -60,7 +61,7 @@ vector intersectMatroids(T& A, U& B, int n) { } } return ans; -} +} // END HASH // Matroid where each element has color // and set is independent iff for each color c // #{elements of color c} <= maxAllowed[c].