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

建议使用的浏览器:

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

6587:Kingdom

题目描述
Tom and Jerry were sent to a kingdom for some intelligence purpose. They were ordered to draw a map of the kingdom.
It's known that the kingdom consists of $n$ cities, numbered from $1$ to $n$, along with $n-1$ bidirectional roads connecting them. The cities form a binary tree, whose root is the kingdom's capital. The nodes on the tree either have no child, or a single left child, or a single right child, or both.
To avoid being caught spying, the commander ordered Tom and Jerry not to directly draw the map, but to record some specific information separately, which combined can deduce what the kingdom looks like.
When on a tree node, Tom was ordered to:
1. Record the label of current node.
2. Go to left child node(if any).
3. Go to right child node(if any).
Jerry was ordered to:
1. Go to left child node(if any).
2. Record the label of current node.
3. Go to right child node(if any).
But things often go south in Tom and Jerry's lives. When returned homeland with their information, they found that some of the numbers they wrote down are spotted. In despair, they decide to calculate how many kinds of form can the kingdom be according to the remaining information. As the number is large, you are only required to print it mod $998244353$.
输入解释
The first line contains an integer $T(1\le T\le 10)$, the number of test cases. Then $T$ cases follow.
For each test case:
In the first line, a integer $n(1\le n\le 100)$, the number of cities in the kingdom.
In the second line, $n$ integers $a_1,a_2,a_3,...,a_n$ separated by space, Tom's sequence.
In the third line, $n$ integers $b_1,b_2,b_3,...,b_n$ separated by space, Jerry's sequence($0\le a_i,b_i\le n$).
The spotted numbers are indicated by $0$.
输出解释
For each test case, output one line containing one integer, the number of corresponding kingdom's form mod $998244353$.
输入样例
1
3
1 0 0
0 0 1
输出样例
4
提示
ere are the 4 possible forms.
来自杭电HDUOJ的附加信息
Recommend

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

源链接: HDU-6587

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

共提交 0

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