#P15529. [ROIR 2015 Day 2] tiling 铺砖
[ROIR 2015 Day 2] tiling 铺砖
Problem Description
During the repair work by the Laboratory IT Department, workers need to replace damaged floor tiles in a corridor. The corridor has size meters. The workers have an unlimited supply of tiles of two sizes: meters and meter. In addition, a tile can be rotated by degrees, so it can be placed either along the corridor or perpendicular to it.
The workers have already started the repair and have placed tiles of size meters at certain positions. To finish the repair, the project manager needs to prepare a plan for the remaining work. He wants to know how many ways there are to tile the remaining cells. This number should be computed modulo .
Task: Write a program that, given the corridor length and the positions of the already placed tiles, determines the number of ways to tile the remaining cells and outputs the result.
Input Format
The first line of the input file contains two integers: — the length of the corridor, and — the number of already placed tiles (, ). The next lines contain two integers and , meaning that the -th tile is placed at meter of the corridor, in row (, ).
Output Format
The output file should contain one integer — the number of ways to tile the remaining cells of the corridor, modulo .
2 0
7
3 0
22
3 1
2 1
8
Hint

Figure 1. All tiling methods in the first sample.

Figure 2. All tiling methods in the third sample.
The already placed tiles are marked in gray.
Grading System and Subtask Description
Subtask 1 (20 points)
- , .
- You get points only if all tests pass.
Subtask 2 (20 points)
- , .
- You get points only if all tests pass.
Subtask 3 (20 points)
- , .
- You get points only if all tests pass.
Subtask 4 (40 points)
- , .
- This subtask has tests. Each test is worth points, and each test is scored independently.
Translation source: GPT 5.2.
Translated by ChatGPT 5