-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: "[CF797F] Mice and Holes" | ||
categories: | ||
- 题目 | ||
date: 2023-10-25 13:38:56 | ||
tags: | ||
- 动态规划 | ||
- 转移优化 | ||
--- | ||
不难发现一个性质,如果某个方案中老鼠 $i,j$ 分别躲进了洞 $u,v$ 中,$x_i<x_j$ 而 $p_u>p_v$,显然调整为让 $i$ 躲进 $v$,$j$ 躲进 $u$,该方案一定不会变劣。因此,将老鼠按照起点所在的位置划分为几个连续段,这些连续段从左往右依次匹配从左往右的洞,一定不劣。 | ||
|
||
考虑朴素 DP,设 $f_{i,j}$ 表示前 $i$ 个洞匹配前 $j$ 个老鼠,老鼠需要走的总长度最小值。有 | ||
|
||
$$ | ||
\begin{aligned} | ||
f_{i,j}&=\min_{k=j-c_i}^j\left\{f_{i-1,k}+\sum_{k<t\le j}|x_k-p_i|\right\}\\ | ||
&=\min_{k=j-c_i}^j\{f_{i-1,k}+s_{i,j}-s_{i,k}\}\\ | ||
&=s_{i,j}+\min_{k=j-c_i}^j\{f_{i-1,k}-s_{i,k}\} | ||
\end{aligned} | ||
$$ | ||
|
||
其中 $s_{i,j}$ 是好求的,并且 $j$ 增大的过程中,$k$ 的合法取值区间单调右移,使用优先队列优化到 $O(nm)$。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: "[CF850C] Arpa and a game with Mojtaba(TODO)" | ||
categories: | ||
- 题目 | ||
date: 2023-10-25 10:07:07 | ||
tags: | ||
- 博弈论 | ||
--- | ||
鉴于每次只能选择一个质因数取,我们可以将原游戏分解为多个游戏的组合,对于质数 $p$,若 $a_i=p^{\alpha_i}k_i$(其中$p\not\mid k_i$),那么 $p$ 对应的游戏为: | ||
|
||
对于集合 $\{\alpha_1,\alpha_2,\cdots,\alpha_n\}$,每次选择正整数 $k$,将集合中所有不小于 $k$ 的数全部减去 $k$,直到所有数全部变为 $0$。 | ||
|
||
由于 $n\le10^9$,$\alpha_i$ 不超过 $30$,可以状压。状态数上界证明先咕着。 | ||
|
||
于是可以通过动态规划求出每个 $p$ 对应的游戏,每个状态的 SG 值。通过 SG 定理可以求得原问题起点的 SG 值。 |