Problem G. Travel
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Description
Alice is currently traveling in a k-dimensional space. She starts at (0, 0, . . . , 0), and she has a total of n teleportation skills. When she uses a teleportation skill, if she is at () and the teleportation skill is (), she will be teleported to (). Teleportation skills can be used in any way. This k-dimensional space is finite, and the size of the i-th dimension is Ni . In other words, for the i-th dimension, the coordinate range is . Alice’s destination is (). There are a total of m black holes in the k-dimensional space, which means Alice cannot reach those positions in any way. Alice wants to know how many ways she can use teleportation skills to reach her destination without passing through any black holes. We consider two different teleportation plans to be different if and only if there exists a step where the two plans use different teleportation skills. Two teleportation skills are considered different if and only if their skill numbers are different. Even if the effects of these two skills are exactly the same, they will still be considered as two separate skills. Since the answer can be large, please output it modulo 998244353.
Input
The input consists of multiple test cases. The first line contains a single integer T() — the number of test cases. Description of the test cases follows. The first line of each test case contains one integers k ()—This means that the space has a total of kdimensions. The next line contains k positive integers Ni ( ), representing the size of the i-th dimension.The next line contains two integers n and m , () , representing the number of teleportation skills and the number of obstacles, respectively. The next n lines contain k non-negative integers (), where (), representing the current teleportation skills. The next m lines contain k non-negative integers (), where (), representing the coordinates of the black holes. It is guaranteed that there is no leap skill corresponding to (. The data ensures that .
Output
For each test case, output an integer representing the number of ways Alice can reach her destination modulo 998244353.
Samples
1
2
100 1000
2 0
1 0
0 1
555294450
Limitation
12s, 512mb for each test case.
杭电“钉耙编程”挑战(纯英纯硬,持续更新ing)
- 状态
- 已结束
- 规则
- ACM/ICPC
- 题目
- 7
- 开始于
- 2023-8-5 12:00
- 结束于
- 2023-9-24 12:00
- 持续时间
- 1200 小时
- 主持人
- 参赛人数
- 28