Skip to content
我爱全世界
By Imacder

Recent Updates

Circles, Pythagorean Theorem, Bipartite Graphs, Gaussian Primes, Number Theory, and Pi
Problem Given $d$, find all $(x,y)$ such that: $$x^2 + y^2 = d$$ Initial Thoughts We can split into odd and even cases: EE $$(2u)^2 + (2v)^2 = d$$ $$d \bmod 4 = 0$$ EO $$(2u+1)^2 + (2v)^2 = d$$
Combinatorics
Inclusion-Exclusion Principle I don't know how I can pass a single problem without this. Some Basic Formulas (1) $$\binom\binom = \binom\binom$$ (2) $$[n = 0] = \sum(-1)^i}$$ Binomial Transform $$f(n) = \sum^ng(i)} \iff g(n) = \sum^nf(i)}$$ $$f(n) = \sum^Mg(i)} \iff g(n) = \sum^Mf(i)}$$ We can also combine the $(-1)^i$ into $g(i)$
DP
What is DP Each DP state is a node on a graph $G$. Each transition is a directed edge on the graph. Typically $G$ is a DAG. We iterate through the DAG to the end points, and these are the answer. DP on DP Sometimes we need to record a complex object for the state. When we do vanilla bitmask DP, the number of states explode. However, there is a large portion of these bitmask states that are invalid. We can push state compression to its limits. We assign each node / state in the DAG an id by running a (partly) brute force search to get all the states. Now we've built the DAG, and we can run the normal DP on the DAG to obtain the answer. Two steps on how to solve this type of DP: 1. Figure out how to check if a given state if valid (answer to the subproblem) 2. Figure out how to use the check to construct solution The checker is an Automata. Monotonic Decision Point
Global BST
we build a
Graph Theory
Network Flow Max Flow (Dinic) Basics We can think of a positive flow $u \rightarrow v$ as a negative flow $v \rightarrow u$. The same idea applies for the capacity of an edge (i.e. $l=-f, r=c-f \iff l=f-c, r=f$). This allows to reverse push flow through an edge to cancel out what had been pushed. Ford-Fulkerson (Naïve Approach) We can repeatedly search for an augmenting path (path with all positive $re$), then push the maximum flow through it (we also need to push negative flow through its reverse edge). If no such edge exists, then break the loop. Dinic We find the naïve approach is way too slow. Dinic still repeatedly searches for augmenting paths, but it does so in batches. $\mathcal(n^2 m)$. Phase 1 BFS We build a depth for all nodes with all the $re 0$ edges. This helps direct the second phase
Hashing
Normal Hash String Hash DO NOT USE $2^$ AS MODULUS!!! It's otherwise quite simple. Sum Hash We can assign a different random value for each element. The hash of a set is its sum. This can support set operations on the fly, but only works for multisets. (P.S. Xor hashing is dangerous, it doesn't support set ops and doesn't support multiset.) We can also estimate the set size with this type of hash. $E = \frac$, where $M$ is the max generated number. (Though we can't use a modulus for this.) Atypical Hash (Sketches) Min Hash

Geometry

Systematic method for solving geometry with Euclidean method.


Algebra

Whatever piece of algebra I found interesting. (May include some physics)


Computer Science

My OI notes.


Thanks to sshwy for the inspiration.
Geometry section heavily references 《核心考点》《怎样应用基本图形分析法添辅助线》.