#P6801. [CEOI 2020] 花式围栏
[CEOI 2020] 花式围栏
Description
As everyone knows, Balázs has the most beautiful fence in the whole town. The fence consists of sections. Each section is a rectangle, and any two adjacent sections are tightly connected. The -th rectangle has height and width . We need to find “fancy rectangles” that satisfy the following conditions:
- Each side of the rectangle is horizontal or vertical, and the length of each side is an integer.
- The distance from the rectangle to the ground is an integer.
- The distance from the rectangle to the left side of the first section of the fence is an integer.
- The rectangle is completely contained within the fence.
Now you need to compute the total number of fancy rectangles. Since this number may be very large, output it modulo .
Input Format
The first line contains an integer , meaning the fence consists of sections.
The second line contains integers. The -th integer is the height of the -th rectangle.
The third line contains integers. The -th integer is the width of the -th rectangle.
Output Format
Output the number of fancy rectangles modulo .
2
1 2
1 2
12
Hint
Sample Explanation 1
The shape of the fence is as shown below:

There are rectangles of the following shape:

There are rectangles of the following shape:

There is rectangle of the following shape:

There are rectangles of the following shape:

There is rectangle of the following shape:

Sample 2
See the additional file.
Subtasks
All test points satisfy: , .
The constraints for each subtask are as follows:
| Subtask ID | Score | Constraints |
|---|---|---|
| Samples | ||
| , and , and | ||
| , or | ||
| All are equal | ||
| , | ||
| No special constraints |
Translated by ChatGPT 5
京公网安备 11011102002149号