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

建议使用的浏览器:

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

5996:dingyeye loves stone

题目描述
dingyeye loves play stone game with you.

dingyeye has an $n$-point tree.The nodes are numbered from $0$ to $n-1$,while the root is numbered $0$.Initially,there are $a[i]$ stones on the $i$-th node.The game is in turns.When one move,he can choose a node and move some(this number cannot be $0$) of the stones on it to its father.One loses the game if he can't do anything when he moves.

You always move first.You want to know whether you can win the game if you play optimally.
输入解释
In the first line, there is an integer $T$ indicating the number of test cases.

In each test case,the first line contains one integer $n$ refers to the number of nodes.

The next line contains $n-1$ integers $fa[1]\cdots fa[n-1]$,which describe the father of nodes $1\cdots n-1$(node $0$ is the root).It is guaranteed that $0\leq fa[i]< i$.

The next line contains $n$ integers $a[0]\cdots a[n-1]$,which describe the initial stones on each nodes.It is guaranteed that $0\leq a[i]<134217728$.

$1\leq T\leq 100$,$1\leq n\leq 100000$.

It is guaranteed that there is at most $7$ test cases such that $n>100$.
输出解释
For each test case output one line.If you can win the game,print "win".Ohterwise,print "lose".
输入样例
2
2
0
1000 1
4
0 1 0
2 3 3 3
输出样例
win
lose
来自杭电HDUOJ的附加信息
Recommend wange2014

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

题目来源 BestCoder Round #90

源链接: HDU-5996

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

共提交 0

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