A13995 | Tiles
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Consider a road consisting of several rows. Each row is divided into several rectangular tiles, and all tiles in the same row are equal. The first row contains exactly one rectangular tile. Look at the picture below which shows how the tiles are arranged.
The road is constructed as follows:
- the first row consists of $1$ tile;
- then $a_1$ rows follow; each of these rows contains $1$ tile greater than the previous row;
- then $b_1$ rows follow; each of these rows contains $1$ tile less than the previous row;
- then $a_2$ rows follow; each of these rows contains $1$ tile greater than the previous row;
- then $b_2$ rows follow; each of these rows contains $1$ tile less than the previous row;
- ...
- then $a_n$ rows follow; each of these rows contains $1$ tile greater than the previous row;
- then $b_n$ rows follow; each of these rows contains $1$ tile less than the previous row.
 An example of the road with $n = 2$ , $a_1 = 4$ , $b_1 = 2$ , $a_2 = 2$ , $b_2 = 3$ . Rows are arranged from left to right. You start from the only tile in the first row and want to reach the last row (any tile of it). From your current tile, you can move to any tile in the next row which touches your current tile.
Calculate the number of different paths from the first row to the last row. Since it can be large, print it modulo $998244353$ .
The road is constructed as follows:
- the first row consists of $1$ tile;
- then $a_1$ rows follow; each of these rows contains $1$ tile greater than the previous row;
- then $b_1$ rows follow; each of these rows contains $1$ tile less than the previous row;
- then $a_2$ rows follow; each of these rows contains $1$ tile greater than the previous row;
- then $b_2$ rows follow; each of these rows contains $1$ tile less than the previous row;
- ...
- then $a_n$ rows follow; each of these rows contains $1$ tile greater than the previous row;
- then $b_n$ rows follow; each of these rows contains $1$ tile less than the previous row.
 An example of the road with $n = 2$ , $a_1 = 4$ , $b_1 = 2$ , $a_2 = 2$ , $b_2 = 3$ . Rows are arranged from left to right. You start from the only tile in the first row and want to reach the last row (any tile of it). From your current tile, you can move to any tile in the next row which touches your current tile.
Calculate the number of different paths from the first row to the last row. Since it can be large, print it modulo $998244353$ .
输入格式
The first line contains one integer $n$ ( $1 \le n \le 1000$ ).
Then $n$ lines follow. The $i$ -th of them contains two integers $a_i$ and $b_i$ ( $1 \le a_i, b_i \le 10^5$ ; $|a_i - b_i| \le 5$ ).
Additional constraint on the input: the sequence of $a_i$ and $b_i$ never results in a row with non-positive number of tiles.
Then $n$ lines follow. The $i$ -th of them contains two integers $a_i$ and $b_i$ ( $1 \le a_i, b_i \le 10^5$ ; $|a_i - b_i| \le 5$ ).
Additional constraint on the input: the sequence of $a_i$ and $b_i$ never results in a row with non-positive number of tiles.
输出格式
Print one integer — the number of paths from the first row to the last row, taken modulo $998244353$ .
输入输出样例
输入 #1
2 4 2 2 3
输出 #1
850
输入 #2
3 4 1 2 3 3 1
输出 #2
10150
输入 #3
8 328 323 867 868 715 718 721 722 439 435 868 870 834 834 797 796
输出 #3
759099319
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted