当前位置: 首页 > news >正文

QOJ2209. Good Game

题目大意

You want to walk from \((0,0, \ldots, 0)\) to \(\left(a_0, a_1, \ldots, a_{n-1}\right)\) in an \(n\)-dimensional space. On each step, you can increase one component of your coordinate vector by one. There are \(m\)obstacles \(p_1, p_2, \ldots, p_m\). You want to find the number of paths that don't pass through the obstacles.

However, this problem is too simple for an ICPC contest in the year 8102. We add one more constraint. For every point \(\left(x_0, x_1, \ldots, x_{n-1}\right)\) on your path, the components of this vector should be non-decreasing: \(x_0 \leq x_1 \leq \ldots \leq x_{n-1}\).

Output the number of paths modulo \(10^9+7\).

The first line contains two integers \(n\) and \(m(1 \leq n \leq 50,0 \leq m \leq 50)\).

The second line contains \(n\) integers \(a_0, a_1, \ldots, a_{n-1}\left(0 \leq a_0 \leq a_1 \leq \ldots \leq a_{n-1} \leq 10^4\right)\), the coordinate vector of your destination.

The following \(m\)lines describe obstacles. The \(i\)-th of these lines contains \(n\) integers \(p_{i, 0}, p_{i, 1}, \ldots, p_{i, n-1} \left(0 \leq p_{i, 0} \leq p_{i, 1} \leq \ldots \leq p_{i, n-1} \leq 10^4\right)\), the coordinate vector of an obstacle.

The starting point, destination, and all the obstacles are distinct.

Output the answer modulo \(10^9+7\).

题解

我们先将 \(a_i\) 不严格递增转换一下。设 \(b_i = a_i + i\),问题转化成从 \((1, 2, \cdots, n)\)\((b_1, b_2, \cdots, b_n)\) 且中途 \(x_i\) 保持严格递增的方案数。

引理 \(1\):不考虑 \(x_i\) 严格递增的限制,此时从 \((s_1, s_2, \cdots, s_n)\) 走到 \((c_1, c_2, \cdots, c_n)\) 的方案数是 \(\binom{\sum c_i - s_i}{c_1-s_1, c_2 - s_2, \cdots, c_n - s_n} = (\sum c_i - s_i)! \times \prod\dfrac{1}{(c_i - s_i)!}\)

下标严格递增可以表示为网格图的形式。我们将第 \(i\) 个维度视为一条从 \((0, i)\)\((\sum (b_i - i), b_i)\) 的路径,这条路径只能向右 / 向右上走。我们将向右上视为 \(+1\),向右视为不变,那么会有如下条件。

  • 由于每次只能移动相邻一格,因此每一步只能有一条路径向右上,其他路径向右。
  • 由于中途 \(x_i\) 要保持递增,因此每条路径都应该互不相交。

引入 LGV 引理。

\(w(P)\) 为路径 \(P\) 上的边权之积,\(e(u, v)\) 表示 \(u\)\(v\) 每一条路径 \(P\)\(w(P)\) 之和,起点、终点的点集为 \(A, B\)。那么有:

\[M = \begin{bmatrix} e(A_1, B_1) & e(A_1, B_2) & \cdots & e(A_1, B_n)\\ e(A_2, B_1) & e(A_2, B_2) & \cdots & e(A_2, B_n)\\ \vdots & \vdots & \ddots & \vdots \\ e(A_n, B_1) & e(A_n, B_2) & \cdots & e(A_n, B_n)\\ \end{bmatrix}\\ \begin{aligned} \text{det}(M) = & \sum_{{\substack{S: A \to B \\ S \text{为不相交路径组}}}} \text{sgn}(\sigma(S)) \prod_{i=1}^{n} \omega(S_i)\\ \iff \sum_{\sigma} \text{sgn}(\sigma) \prod_{i = 1}^n e(A_i, B_{\sigma_i}) = & \sum_{{\substack{S: A \to B \\ S \text{为不相交路径组}}}} \text{sgn}(\sigma(S)) \prod_{i=1}^{n} \omega(S_i) \end{aligned} \]

引入一个平凡的 LGV 引理的推论。

\(g(S)\) 为该路径组的权值,设 \(f(\sigma)\)\(A_i \to B_{\sigma_i}\) 的所有路径组的权值之和。

\[\begin{aligned} \sum_{\sigma} \text{sgn}(\sigma) \prod_{i = 1}^n e(A_i, B_{\sigma_i}) = & \sum_{{\substack{S: A \to B \\ S \text{为不相交路径组}}}} \text{sgn}(\sigma(S)) \prod_{i=1}^{n} \omega(S_i)\\ \iff \sum_{\sigma} \text{sgn}(\sigma) f(\sigma) = & \sum_{{\substack{S: A \to B \\ S \text{为不相交路径组}}}} \text{sgn}(\sigma(S)) g(S)\\ \end{aligned} \]

回到原题。我们设推论中的 \(g(S)\) 表示路径组 \(S\) 是否满足以上两个条件,\(f(\sigma)\) 就是所有 \(S: (0, i) \to (\sum(b_{\sigma_i} - \sigma_i), b_{\sigma_i})\)\(g(S)\) 之和。由引理 \(1\)\(f(\sigma) = (\sum b_{\sigma_i} - i)! \times \prod\dfrac{1}{(b_{\sigma_i} - i)!}\)

考虑一个路径组 \(S\)。由于这个路径起终点和网格图的特殊性,当 \(\sigma(S)\) 逆序对大于 \(0\) 时,\(S\) 一定会相交。因此,对于所有 \(\sigma(S)\) 逆序对大于 \(0\)\(S\),使得 \(g(S) = 0\)

\(A_i = (0, i), B_i = (\sum(b_{i} - i), b_{i})\)。那么,就有:

\[M = \begin{bmatrix} \dfrac{1}{(b_1 - 1)!} & \dfrac{1}{(b_2 - 1)!} & \cdots & \dfrac{1}{(b_n - 1)!}\\ \dfrac{1}{(b_1 - 2)!} & \dfrac{1}{(b_2 - 2)!} & \cdots & \dfrac{1}{(b_n - 2)!}\\ \vdots & \vdots & \ddots & \vdots \\ \dfrac{1}{(b_1 - n)!} & \dfrac{1}{(b_2 - n)!} & \cdots & \dfrac{1}{(b_n - n)!}\\ \end{bmatrix}\\ \begin{aligned} & g(S: \{A_i \to B_i\})\\ = & \sum_{{\substack{S: A \to B \\ S \text{为不相交路径组}}}} \text{sgn}(\sigma(S)) g(S)\\ = & \sum_{\sigma} \text{sgn}(\sigma) f(\sigma)\\ = & \sum_{\sigma} \text{sgn}(\sigma) (\sum b_{\sigma_i} - i)! \times \prod\dfrac{1}{(b_{\sigma_i} - i)!}\\ = & (\sum b_{\sigma_i} - i)! \sum_{\sigma} \text{sgn}(\sigma) \times \prod\dfrac{1}{(b_{\sigma_i} - i)!}\\ = & (\sum b_{\sigma_i} - i)!\text{det}(M) \end{aligned} \]

\(M\) 的行列式求出即可。

http://www.jsqmd.com/news/312505/

相关文章:

  • 2026成都育儿嫂培训避坑指南:哪个月嫂培训机构更靠谱?
  • 2026分期乐京东e卡回收4种方式分享!
  • CSS 学习笔记 (2) 盒子模型
  • edu116 DE
  • 反射运行时构造泛型的底层机制(大白话全景版)
  • 网络安全入门学习路线 怎样科学的进行网络安全学习
  • Burp Suite Professional 2025.12.5 发布 - Web 应用安全、测试和扫描
  • VMware NSX 4.2.3.3 发布,新增功能概览
  • 基于STM32单片机的三轮竞速智能车系统的设计与研究
  • 2026年海南进口美妆批发品牌盘点,这些值得关注,广州做得好的进口美妆批发公司哪家好聚焦优质品牌综合实力排行
  • 科学方法唤醒大脑学习潜能
  • 2026年管材市场风云变幻,厂商引领新潮流,管材厂家推荐中亿百年引领行业标杆
  • 基于1百万物种的百亿级基因数据,英伟达等构建EDEN系列模型,基因组与蛋白质预测能力达 SOTA
  • 抗辐照MCU芯片在无人叉车领域的性能评估与选型建议 - 实践
  • Prometheus 和 Grafana 监控 PostgreSQL
  • 强烈安利10个AI论文工具,专科生搞定毕业论文不求人!
  • 2026年国内热门的制冷设备订做厂家口碑推荐,冷却塔填料/冷却水塔/方形横流冷却塔/闭式冷却塔,制冷设备订制厂家有哪些
  • 学霸同款2026 AI论文平台TOP10:研究生开题报告神器测评
  • CMS站群批量导入WORD图片到KindEditor的最佳实践?
  • 汽车制造行业KindEditor如何处理设计图WORD粘贴?
  • 2026年目前质量好的登车桥生产商排行榜,升降平台/移动登车桥/液压升降平台/液压升降机/升降机,登车桥供应商联系方式
  • 2026年 工业省电空调厂家推荐排行榜:蒸发冷环保省电空调,工业蒸发冷省电空调,专业节能技术实力与市场口碑深度解析
  • 2026年NMN哪个品牌好?全球NMN品牌前十名权威排行榜为您揭晓
  • 西安本地口碑好的宝宝起名公司推荐
  • 割点、割边及双联通分量
  • 2026年 空气能热泵设备厂家推荐排行榜:涵盖一体机组、高温热水器、泳池恒温、烘干机及工业商用全场景解决方案
  • 2026最新家电维修服务推荐!空调维修/冰箱维修/洗衣机维修优质服务商权威榜单发布,高效解决家电故障难题
  • 数据结构—栈和队列 - 实践
  • 2026年天津离婚纠纷律所联系电话推荐:五大优选机构详解
  • NMN怎么选不踩坑?NMN排行榜推荐,帮你把钱花在刀刃上