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

建议使用的浏览器:

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

7193:Cube Rotate

题目描述
Why does YahAHa always like cubes?

YahAHa has a special cube. Each side of cube has a number $x$ $(1\le x\le 1000)$. At the beginning, YahaHa placed the cube on the table. Then rolled the cube $n$ $(1\le n\le 2\times 10^5$ ) times, each time along one edge of bottom side.It means rotate top face to other faces.

YahAHa have a number $x$,$x$ is $1$ in the beginning.After each roll, YahAHa multiply the number on the front side of the cube to $x$. The product was so large that YahAHa write down the product module $998244353$.

Carelessly, YahAHa forgot $m$ $(1\le m\le 20)$ of these rolling directions. But YahAHa has written down the start state of the cube, the final state, and the product of numbers on the front side after module.

Can you tell YahAHa that how many different ways of rolling that satisfy all the conditions?
输入解释
Each test contains multiple test cases. The first line contains the number of test cases $(1 \le T \le 10)$. Description of the test cases follows.

The first line of the input contains only one integers $n$ $(1\le n \le 2\times 10^5)$ indicating the number of rolls of the cube.

The next line contains $n$ integers. The $i$-th integer $a_i$ $(0\le a_i\le 4)$ indicating the $i$-th roll. $a_i = 1$ means rotate top face to front; $a_i = 2$ means rotate top face to back; $a_i = 3$ means rotate top face to left; $a_i = 4$ means rotate top face to right; $a_i = 0$ means YahAHa has forgotten the direction of this roll;

The next line contains $6$ distinct integers indicating the start state of the cube.

The next line contains $6$ distinct integers indicating the final state of the cube.

The state of the cube is represented as $6$ integers. The $6$ integers are sorted by front, back, left, right, top and bottom sides.

The last line contains one integer indicating the product of numbers on the front side module $998244353$.

It's guaranteed that there are at most $5$ cases such that $n\geq 10^5,m\geq 20$ .
输出解释
For each test case:

Print one interger in one line indicating the answer.
输入样例
1
7
3 0 4 2 0 4 4
1 6 2 3 4 5
1 6 4 5 3 2
3
输出样例
1
来自杭电HDUOJ的附加信息
Hint The rotate direction of example: 3 4 4 2 1 4 4Change of front side:1->1->1->1->3->1->1->1stretch-out view:

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

源链接: HDU-7193

最后修改于 2022-09-15T06:17:16+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
14000/7000MS(Java/Others) 524288/262144K(Java/Others)