当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7109:Random Walk

题目描述
Give you an undirected simple graph with $n$ vertices and $m$ edges and there are $a_i$ coins on the $i$th edge. Kris will randomly choose a starting vertex $s (1 \leq s < n)$ and each second he will uniformly randomly walk to another adjacent vertex until reach the vertex $n$. The coins on edges will decay to a half per second but no less than $b_i$, formally if Kris walk through the $i$th edge at $t (t \geq 1)$ second, he will collect $max\{\lfloor \frac{a_i}{2^{t-1}} \rfloor, b_i\}$ coins. The graph will vary over time, after each change you should answer the expected coins he will collect. It is guaranteed that the graph is connected.
输入解释
This problem only contains one test case.

The first line of the input contains three integers $n, m, q (2 \leq n \leq 500, 1 \leq m \leq 10^4, 1 \leq q \leq 10^6)$. The next line contains $n - 1$ integers $w_i (1 \leq w_i \leq 10^4)$. The probability of vertex $x$ as the starting vertex can be represented as follow:
\begin{equation}
P_x = \frac{w_x}{\sum_{i=1}^{n-1}w_i} \tag{1}
\end{equation}
The next $m$ lines contains four integers $x, y, a, b (1 \leq x, y \leq n, 1 \leq b \leq a \leq 100)$, representing an edge between $x$ and $y$ with $a$ coins initially and $b$ coins finally.

Then $q$ lines follow, each line has one of the following format:

  • 1 x y a b $(1 \leq x, y \leq n, 1 \leq b \leq a \leq 100)$, representing changing the initial coins on $(x, y)$ to $a$ and final coins on $(x, y)$ to $b$. It is guaranteed that there is an edge between $x$ and $y$.

  • 2 x c $(1 \leq x \leq n - 1, 1 \leq c \leq 10^4)$, representing changing $w_x$ to $c$. Note that after this change not only $P_x$ but all probabilities will change according to formula (1). It is guaranteed that the number of this change is no more than $n$.


Note that the changes are persistent and the $(i+1)$th change is based on the $i$th change.
输出解释
Before the first change and after each change, output the expected coins Kris will collect. Assume that the answer is $\frac{P}{Q}$, then you should output $P \cdot Q^{-1} \mod 998244353$, where $Q^{-1}$ denotes the multiplicative inverse of $Q$ modulo 998244353.

Notes:

  • After Kris collect coins on an edge, the coins on it will not vanish. When he visit the edge the second time, he will collect coins on it again but the number may change.

  • At the very begin, the expected coins which Kris will collect for starting vertices $1, 2, 3$ are $9$ coins, $8$ coins, $5$ coins respectively, so the answer is $9 \times \frac{1}{3} + 8 \times \frac{1}{3} + 5 \times \frac{1}{3} = \frac{22}{3}$.


输入样例
4 3 3
1 1 1
1 2 1 1
2 3 1 1
3 4 1 1
1 1 2 2 1
2 1 2
1 2 3 4 2
输出样例
332748125
831870302
623902729
374341644

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7109

最后修改于 2021-10-23T19:11:31+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
15000/9000MS(Java/Others) 262144/262144K(Java/Others)