From f49fec10c62aed8c1c280626abcff9e3a581b1c0 Mon Sep 17 00:00:00 2001 From: manoflearning <77jwk0724@gmail.com> Date: Wed, 14 Jan 2026 01:19:06 +0900 Subject: [PATCH] feat: introduce random_facts.txt --- .gitignore | 1 + README.md | 2 +- src/8-misc/facts.txt | 0 src/8-misc/random_facts.txt | 22 +++++++++++++++++++ ..._manhattan_distance_chebyshev_distance.txt | 20 ----------------- 5 files changed, 24 insertions(+), 21 deletions(-) delete mode 100644 src/8-misc/facts.txt create mode 100644 src/8-misc/random_facts.txt delete mode 100644 src/8-misc/rotation_matrix_manhattan_distance_chebyshev_distance.txt diff --git a/.gitignore b/.gitignore index 9099272..eae46d1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .venv .DS_Store .ruff_cache +references/ diff --git a/README.md b/README.md index d60d191..099e3d8 100644 --- a/README.md +++ b/README.md @@ -67,9 +67,9 @@ My implementations of various data structures and algorithms for competitive pro - [`dp_opt.cpp`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/dp_opt.cpp) - [`diff_cons.cpp`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/diff_cons.cpp) - [`num_frac.cpp`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/num_frac.cpp) + - [`random_facts.txt`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/random_facts.txt) - [`rec_kitamasa.cpp`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/rec_kitamasa.cpp) - [`rnd.cpp`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/rnd.cpp) - - [`rotation_matrix_manhattan_distance_chebyshev_distance.txt`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/rotation_matrix_manhattan_distance_chebyshev_distance.txt) - [`search_ternary.cpp`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/search_ternary.cpp) - [`seq_lis.cpp`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/seq_lis.cpp) - [`simd.cpp`](https://github.com/manoflearning/cp-reference-codes/blob/main/src/8-misc/simd.cpp) diff --git a/src/8-misc/facts.txt b/src/8-misc/facts.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/8-misc/random_facts.txt b/src/8-misc/random_facts.txt new file mode 100644 index 0000000..7bbb17f --- /dev/null +++ b/src/8-misc/random_facts.txt @@ -0,0 +1,22 @@ +Random Facts (ICPC Team Note) + +- Tiny identities / tricks (no code), meant to be printed and skimmed quickly. +- Keep each item short: setup -> formulas -> use -> pitfall. + +------------------------------------------------------------------------------- + +GEOMETRY + +45deg transform: Manhattan <-> Chebyshev on Z^2 + Setup: u = x + y, v = x - y. + L1: |dx| + |dy| = max(|du|, |dv|). + L∞: max(|dx|, |dy|) = (|du| + |dv|) / 2. + Use: max Manhattan over points = max( max(u)-min(u), max(v)-min(v) ). + Note: du, dv have same parity -> (|du|+|dv|) is even -> /2 is integer. + Why: max(|a+b|,|a-b|)=|a|+|b| and |a+b|+|a-b|=2max(|a|,|b|). + +GRAPH + +Complete bipartite K_{n,m}: number of spanning trees + Formula: tau(K_{n,m}) = n^{m-1} * m^{n-1}. + Why: Matrix-Tree theorem (Kirchhoff). diff --git a/src/8-misc/rotation_matrix_manhattan_distance_chebyshev_distance.txt b/src/8-misc/rotation_matrix_manhattan_distance_chebyshev_distance.txt deleted file mode 100644 index 38c3b59..0000000 --- a/src/8-misc/rotation_matrix_manhattan_distance_chebyshev_distance.txt +++ /dev/null @@ -1,20 +0,0 @@ -Rotation Matrix (In Two Dimensions) - -x' = x * cosθ - y * sinθ -y' = x * sinθ + y * cosθ - -Manhattan Distance, Chebyshev Distance - -For any two points (x1, y1), (x2, y2) on two-dimensional coordinates, -- the Manhattan distance is |x1 - x2| + |y1 - y2|. -- the Chebyshev distance is max(|x1 - x2|, |y1 - y2|). - -Relationship between Manhattan distance and Chebyshev distance - -Let x1' = x1 - y1, y1' = x1 + y1, -x2' = x2 - y2, y2' = x2 + y2. (using Rotation matrix) - -Then max(|x1 - x2|, |y1 - y2|) -= (|x1' - x2'| + |y1' - y2'|). - -Thus, Manhattan distance can be solved by replacing it with Chebyshev distance, and vice versa. \ No newline at end of file