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

建议使用的浏览器:

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

6566:The Hanged Man

题目描述
The Hanged Man shows a man suspended from a t-shaped cross made out of living wood. The man is hanging upside-down, viewing the world from a completely different perspective. His facial expression is calm and serene, suggesting that he is in this hanging position by his own choice.

Bobo has two arrays $a_1$, $a_2$, . . . , $a_n$ and $b_1$, $b_2$, . . . , $b_n$. For each set $S$ $\subseteq$ {1, 2, . . . , $n$}, he denotes $A(S)$ = $\sum\limits_{i \subseteq S}$ $a_i$ and $B(S)$ = $\sum\limits_{i \subseteq S}$ $b_i$.
Bobo also has a tree of $n$ vertices conveniently labeled with 1, 2, . . . , $n$. A set $S$ $\subseteq$ {1, 2, . . . , $n$} is an independent set if and only if for any two vertices $u$ and $v$ connected directly on the tree, either $u$ $\notin$ $S$ or $v$ $\notin$ $S$ holds.
For each $x$ $\subseteq$ {1, 2, . . . , $m$}, Bobo would like to find f(x) which is the number of independnt set S with $A(S)$ = $x$ and $B(S)$ maximized.
Formally, f(x) = |{$S$ : $S$ $\subseteq$ $I$, $A(S)$ = $x$, $B(S)$ = $max^{A(T)=x}_{T \subseteq I}$ $B(T)$}| where $I$ stands for the family of the independent sets. Suppose there is no $A(S)$ = $x$ for some $i$, then $f(x)$ = 0.
Find out the value of f(1), f(2), . . . , f(m).
输入解释
The first line of the input contains one integer $T$ ≤ 20, denoting the number of testcases. Then $T$ testcases follows, separated with no extra blank lines.
The first line of each test case contains two integers $n$ and $m$.
The i-th of the following n lines contains two integers $a_i$ and $b_i$.
The i-th of the last (n - 1) lines contains two integers $u_i$ and $v_i$ which denotes an edge connected vertices $u_i$ and $v_i$.

  • 1 ≤ n ≤ 50

  • 1 ≤ m ≤ 5000

  • 1 ≤ $a_i$ ≤ m

  • 1 ≤ $b_i$ ≤ $10^6$

  • 1 ≤ $u_i$, $v_i$ ≤ $n$
  • 输出解释
    For each testcase, first print "Case $i$:" in one line ($i$ indicates the case number, starting from 1). In the line, print m integers which denote f(1), f(2), . . . , f(m).
    输入样例
    3
    3 2
    1 1
    1 1
    1 1
    1 2
    1 3
    4 5
    1 1
    2 2
    3 2
    2 1
    1 2
    2 3
    3 4
    5 10
    3 1
    2 2
    4 4
    7 8
    5 16
    1 2
    1 3
    2 4
    2 5
    输出样例
    Case 1:
    3 1
    Case 2:
    1 1 2 2 0
    Case 3:
    0 1 1 1 1 1 1 1 1 1
    来自杭电HDUOJ的附加信息
    Recommend chendu

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

    源链接: HDU-6566

    最后修改于 2020-10-25T23:32:23+00:00 由爬虫自动更新

    共提交 0

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