diff --git a/algorithms/graph/bellman_ford.cpp b/algorithms/graph/bellman_ford.cpp index 7bb5b3d21a3079d61f4ba79157494060f2bd49ee..5d54ae41244d63fb38633148d469635cb247cfe5 100644 --- a/algorithms/graph/bellman_ford.cpp +++ b/algorithms/graph/bellman_ford.cpp @@ -1,6 +1,6 @@ /// Bellman-Ford /// -/// Time: O(V*E) +/// Time: O(V * E) /// Space: O(V + E) struct BellmanFord { diff --git a/algorithms/graph/bipartite_match.cpp b/algorithms/graph/bipartite_match.cpp index dee720862aa0566ae63303b2693a4746bf8a81c7..e643c3cd2a9d8683ce7cf07b29c8fd80ab15e49c 100644 --- a/algorithms/graph/bipartite_match.cpp +++ b/algorithms/graph/bipartite_match.cpp @@ -1,7 +1,7 @@ /// Bipartite Matching /// -/// Time: O(V*E) -/// Space: O(V*E) +/// Time: O(V * E) +/// Space: O(V * E) vector<int> graph[MAX]; diff --git a/algorithms/graph/dinic.cpp b/algorithms/graph/dinic.cpp index 5925a25ed68c1a297c42f4d7d5157f7f690d8468..0e96c6ee4b67ac4714da7233422210e6cda49652 100644 --- a/algorithms/graph/dinic.cpp +++ b/algorithms/graph/dinic.cpp @@ -1,7 +1,9 @@ /// Dinic's /// -/// Time: O(E*V^2) +/// Time: O(E * V^2) /// Space: O(V + E) +/// +/// Status: Tested (URI2882) struct Dinic { struct Edge { int u, f, c, r; }; @@ -25,7 +27,7 @@ struct Dinic { queue<int> Q; Q.push(s); - mset(depth, -1); + fill(all(depth), -1); depth[s] = 0; while (!Q.empty()) { diff --git a/algorithms/graph/edmonds_karp.cpp b/algorithms/graph/edmonds_karp.cpp index 86d893a10c4f869ce0f6eb2fbc81b344441e9556..61703a5fd3a283b7569f9bc953a4233e77da8be4 100644 --- a/algorithms/graph/edmonds_karp.cpp +++ b/algorithms/graph/edmonds_karp.cpp @@ -1,6 +1,6 @@ /// Edmonds-Karp /// -/// Time: O(V*E^2) +/// Time: O(V * E^2) /// Space: O(V^2) int rg[MAX][MAX]; diff --git a/algorithms/graph/ford_fulkerson.cpp b/algorithms/graph/ford_fulkerson.cpp index 7429f771659c801204c1074862f6bffe1e073f35..b04b1ca953a907123557667251c133b800664bd5 100644 --- a/algorithms/graph/ford_fulkerson.cpp +++ b/algorithms/graph/ford_fulkerson.cpp @@ -1,6 +1,6 @@ /// Ford-Fulkerson /// -/// Time: O(Ef) +/// Time: O(E * f) /// Space: O(V^2) int rg[MAX][MAX]; diff --git a/algorithms/graph/hopcroft_karp.cpp b/algorithms/graph/hopcroft_karp.cpp index f52187a53e2814d8493e397d841ab8a78fb7e3b3..b8abdceb193c3701da724cbf5800ef4f5178748d 100644 --- a/algorithms/graph/hopcroft_karp.cpp +++ b/algorithms/graph/hopcroft_karp.cpp @@ -1,6 +1,6 @@ /// Hopcroft-Karp /// -/// Time: O(E*sqrt(V)) +/// Time: O(E * sqrt{V}) /// Space: O(V + E) vector<int> graph[MAX]; diff --git a/algorithms/math/euler_totient.cpp b/algorithms/math/euler_totient.cpp index 97b0320ca2c9525ef00ee8292a8d9b6fcf4b0058..0ffdfdce57c02287edd4563fda695d365d7874ea 100644 --- a/algorithms/math/euler_totient.cpp +++ b/algorithms/math/euler_totient.cpp @@ -1,6 +1,6 @@ /// Euler Totient ($\phi$) /// -/// Time: O(sqrt(n)) +/// Time: O(sqrt{n}) /// Space: O(1) struct EulerTotient { diff --git a/algorithms/math/matrix.cpp b/algorithms/math/matrix.cpp index fa67642a595ed9e8809b29a1062981d469828ec7..128ef5565dd3787c7178423a36975616b2c343b0 100644 --- a/algorithms/math/matrix.cpp +++ b/algorithms/math/matrix.cpp @@ -1,6 +1,6 @@ /// Matrix /// -/// Space: O(r*c) +/// Space: O(R * C) template <typename T> struct matrix { diff --git a/algorithms/math/sieve_of_eratosthenes.cpp b/algorithms/math/sieve_of_eratosthenes.cpp index 1bcd2c51b73176ee94959dd170934b21dc079264..853de78926b7c9ea83fa4511a4ebefc6ac4575d1 100644 --- a/algorithms/math/sieve_of_eratosthenes.cpp +++ b/algorithms/math/sieve_of_eratosthenes.cpp @@ -1,6 +1,6 @@ /// Sieve of Eratosthenes /// -/// Time: O(n*log(log(n))) +/// Time: O(n * log log n) /// Space: O(n) struct Sieve { diff --git a/algorithms/paradigm/edit_distance.cpp b/algorithms/paradigm/edit_distance.cpp index 5ac6c22efbc215f87630db5bf8197c0f1603c1d7..71ff93cdef0506b4ce32b2a82645c2f216abedd2 100644 --- a/algorithms/paradigm/edit_distance.cpp +++ b/algorithms/paradigm/edit_distance.cpp @@ -1,7 +1,7 @@ /// Edit Distance /// -/// Time: O(m*n) -/// Space: O(m*n) +/// Time: O(m * n) +/// Space: O(m * n) struct EditDistance { vector<vector<int>> dp; diff --git a/caderno.pdf b/caderno.pdf index 887d01009ac3ee9c9c93306db15ecca5c183791b..7fc0671ca628986b8ef7296abdaa30054a7e47e9 100644 Binary files a/caderno.pdf and b/caderno.pdf differ diff --git a/notebook/gen_latex.py b/notebook/gen_latex.py index 385e53086c40874c8d4cc6185021db709ece7600..90a150492292f1184010bd9844c340c2bcbcd149 100644 --- a/notebook/gen_latex.py +++ b/notebook/gen_latex.py @@ -48,7 +48,7 @@ class LatexGenerator: self.header = {} self.code, self.raw_header = [], [] - self.sections = ['Description', 'Time', 'Space', 'Include'] + self.sections = ['Description', 'Time', 'Space', 'Include', 'Status'] self._parse_source(source) self._parse_header() @@ -120,6 +120,15 @@ class LatexGenerator: write('\\\\\n') write('~\\\\\n') + # Replaces text with LaTeX on Big-O notations. + def to_big_o(expr): + expr = expr.replace('O', '\\mathcal{O}') + expr = expr.replace('log', '\\log') + expr = expr.replace('*', '\\times') + expr = expr.replace('sqrt', '\\sqrt') + return expr + + # Outputs time or space complexity. def output_complexity(comp): if comp in self.header: write('\\textbf{\\footnotesize %s: }' % comp) @@ -130,10 +139,10 @@ class LatexGenerator: line = i[1:].split(':') write('\\item{\\footnotesize{%s: $%s$}}\n' % (line[0].strip().replace('_', '\\_'), - line[1].strip())) + to_big_o(line[1].strip()))) write('\\end{compactitem}\n') else: - write('\\footnotesize{$%s$}\n' % self.header[comp][0]) + write('\\footnotesize{$%s$}\n' % to_big_o(self.header[comp][0])) return True return False