Solutions

Matrix ExponentiationCombinatorial SignificanceLinear Dynamic Programming (Linear DP)Mathematical Derivation Miscellaneous
给定 $n$ , $p$ , $r$ , $k$ ( $1\le n\le 10^9$ , $0\le r,2\le p\le 2^{30}-1$ ),求 $$\sum_{i\bmod k=r}{nk\choose i}\bmod p $$ 题解 $$\begin{aligned}&\sum_{i\bmod k=r}{nk\choose i}\\=&\sum_{i\bm …
Jayun 发布于 2024-03-01 14:13:10
10
Hungary
Maximize Mex 题面 在一所学校里有 $n$ 名学生和 $m$ 个社团,社团被编号为 $1$ ~ $m$ 。第 $i$ 个学生有一个能力值 $p_i$ ,且属于社团 $c_i$ (每个学生恰好属于一个社团) 。 学校将要举行一个为期 $d$ 天的活动,每天学校要举行一场程序设计比赛 —— 校长将会从每个社团中各选出一个人(如果某个社团没有人,就不选)组成一个 …
Jayun 发布于 2024-02-29 18:32:31
00
Permutation and CombinationVandermonde ConvolutionCountPrinciple of Inclusion-Exclusion
Koxia and Sequence 题面 给定非负整数 $n,x,y$ ,对于所有满足 $\sum_{i=1}^n a_i=x,\text{OR}_{i=1}^n a_i=y$ ,的序列 $\{a_n\}$ 。求 $\bigoplus_{i=1}^n a_i$ 的异或和。 $1 \leq n < 2^{40} , 0 \leq x < 2^{60} , 0 \leq …
Jayun 发布于 2024-02-28 22:00:46
00
Minimum CutMaximum FlowShortest Path Faster Algorithm (SPFA)
题面 有 $n$ 个变量 $w[1]\sim w[n]$ ,每个变量的值为 $W$ 或 $-W$ 。 有 $p$ 个公式 $f(i)=a_i|w[x_i]-w[y_i]|+b_i|w[y_i]-w[z_i]|+c_i|w[z_i]-w[x_i]|+d_i(w[x_i]-w[y_i])+e_i(w[y_i]-w[z_i])+f_i(w[z_i]-w[x_i])$ 。 其中 $ …
Jayun 发布于 2024-02-28 20:20:20
00
Mathematical Derivation MiscellaneousLinear Dynamic Programming (Linear DP)
[AGC020C] Median Sum 题面 给定由 $n$ 个正整数 $a _ {1, 2, \cdots, n}$ 组成的可重集合,请求出它的非空子集的和的中位数。 $1\ \leq\ n\ \leq\ 2000, 1\ \leq\ A_i\ \leq\ 2000$ 题解 发现重要性质,非空子集的和在值域上是对称的。bitset 背包即可。 代码 const int N = 20 …
Jayun 发布于 2024-02-28 18:37:23
00
Mathematical Derivation MiscellaneousCount
题面 有一个 $1\sim n$ 的排列 $\{p_i\}$ ,对应了 $i$ 条有向边为 $(i,p_i)$ 的图。由于 $p_i$ 是排列,可以证明图由若干个环组成。你希望知道有多少种可能的排列 $\{p_i\}$ ,使得图中每一个环长度都为偶数,答案对 $998244353$ 取模。其中一部分 $p_i$ 已经给定。 $n\leq 10^5$ 。 题解 特 …
Jayun 发布于 2024-02-28 18:33:50
00
Pólya Enumeration Theorem (PET)Mathematical Derivation Miscellaneous
题面 题解 Polya 计数。旋转 2 个置换,翻转 3 个置换,单位置换 1 个。 旋转的循环就是每层(?)3 个转,反转就是对角线外两两转。 代码 const int N = 0, bN = 210; inline ll Read() { ll x = 0, f = 1; char c = getchar(); while (c != '-' && (c < …
Jayun 发布于 2024-02-28 17:31:25
00
Pólya Enumeration Theorem (PET)Linear Dynamic Programming (Linear DP)
题意 摆。 题解 用背包维护不定点,套 Burside 引理。 代码 const int N = 30, M = 70; inline ll Read() { ll x = 0, f = 1; char c = getchar(); while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == …
Jayun 发布于 2024-02-28 15:59:44
00
Pólya Enumeration Theorem (PET)
题目 给定一个 $n$ 个点, $n$ 条边的环,有 $n$ 种颜色,给每个顶点染色,问有多少种本质不同的染色方案,答案对 $10^9+7$ 取模 $n \leq 10^9,t \leq 10^3$ 题解 对于一个置换 $\tau_k=\begin{pmatrix} 1 & 2 & \dots & n-k & n-k+1 & n-k+2 …
Jayun 发布于 2024-02-28 08:02:32
00
Combinatorial SignificanceCountPermutation and Combination
题意 $n$ 个盒子,总共 $S$ 个球,初始状态 $\{a_i\}$ ,盒子之间边权 $w_i$ 表示一个球经过这条边的花费。问对于所有状态花费之和。 $n\leq5\times10^5, S\leq2\times10^6$ 。 题解 这种题就要考虑小贡献,对于每条边的贡献,插板法易得 $$\begin{aligned} &\sum\limits_{i=1}^{n-1}\ …
Jayun 发布于 2024-02-27 20:42:16
00