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

建议使用的浏览器:

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

5614:Baby Ming and Matrix tree

题目描述
Give a $2*2$ 01-matrix A, which can deal with the following $2$ kinds of transformation:

**Rotation transformation**: clockwise rotation. Move $A(i, j)$ to $A(j,1- i)$

**Replace**: replace the matrix $A$ into matrix $B$.

Given a tree, there is a matrix $A_i$ in every node of the tree, Baby Ming likes to play the matrix in the tree. Every time, Baby Ming choose two node $a, b$ in the tree and change all the matrixes in the path from $a$ to $b$ into matrix $B$ by the above two kinds of transformation.

Suppose rotation transformation takes $2$ seconds every time while replace takes $10$. Baby Ming wants to know the minimum time it costs.
输入解释
In the first line contains a single positive integer $T$, indicating number of test case.

For every test case:

In the first line there is a number $n$ to show the tree has $n$ nodes.

In the next $n-1$ lines, each line contains $2$ integer $a, b$, indicate the edge between $a$ and $b$.

In the next $n*2$ lines, each line contains $2$ numbers $01$, indicate the matrix $A_i$ in the node $i$.

Input a positive integer $q$, indicate the number of queries.

For each query:

In the first line there is two positive numbers $a, b$.

In the second line and third line there is a $2*2$ 01-matrix B, It represents select two nodes $a, b$, transform all the matrix $A_i$ in the path from $a$ to $b$ into matrix $B$

**(matrix $A_i, B$ consist by $2$ zeros and $2$ ones)**

$1 \leq T \leq 30, 1 < n \leq 20000, 1 \leq q \leq 20000, 1 \leq a, b \leq n$
输出解释
For each of $Q$ operation, print one line to show minimum time the change needed.
输入样例
1
5
3 4
1 2
2 5
1 4
0 0
1 1
0 1
1 0
1 1
0 0
0 1
0 1
1 0
0 1
3
1 5
0 1
1 0
2 3
0 1
0 1
1 2
0 0
1 1
输出样例
12
22
4
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5614

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

共提交 0

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