CF1473G.Tiles

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 11 tile;
  • then a1a_1 rows follow; each of these rows contains 11 tile greater than the previous row;
  • then b1b_1 rows follow; each of these rows contains 11 tile less than the previous row;
  • then a2a_2 rows follow; each of these rows contains 11 tile greater than the previous row;
  • then b2b_2 rows follow; each of these rows contains 11 tile less than the previous row;
  • ...
  • then ana_n rows follow; each of these rows contains 11 tile greater than the previous row;
  • then bnb_n rows follow; each of these rows contains 11 tile less than the previous row.

An example of the road with n=2n = 2, a1=4a_1 = 4, b1=2b_1 = 2, a2=2a_2 = 2, b2=3b_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 998244353998244353.

考虑一条由若干行组成的道路。每行被划分为若干个矩形砖块,且同一行内的所有砖块均相同。第一行恰好包含一个矩形砖块。请参见下方图片,了解砖块的排列方式。

该道路按如下方式构建:

  • 第一行包含 11 块砖;
  • 接着是 a1a_1 行,每一行比前一行多 11 块砖;
  • 接着是 b1b_1 行,每一行比前一行少 11 块砖;
  • 接着是 a2a_2 行,每一行比前一行多 11 块砖;
  • 接着是 b2b_2 行,每一行比前一行少 11 块砖;
  • …
  • 接着是 ana_n 行,每一行比前一行多 11 块砖;
  • 接着是 bnb_n 行,每一行比前一行少 11 块砖。

一个示例:n=2n = 2,a1=4a_1 = 4,b1=2b_1 = 2,a2=2a_2 = 2,b2=3b_2 = 3。各行从左至右排列。

你从第一行中唯一的砖块出发,目标是到达最后一行(到达最后一行中任意一块砖均可)。在当前砖块上,你可以移动到下一行中与当前砖块相接触的任意一块砖。

请计算从第一行到最后一行的不同路径总数。由于结果可能很大,请对 998244353998244353 取模后输出。

输入格式

The first line contains one integer nn (1≤n≤10001 \le n \le 1000).

Then nn lines follow. The ii-th of them contains two integers aia_i and bib_i (1≤ai,bi≤1051 \le a_i, b_i \le 10^5; ∣ai−bi∣≤5|a_i - b_i| \le 5).

Additional constraint on the input: the sequence of aia_i and bib_i never results in a row with non-positive number of tiles.

第一行包含一个整数 nn(1≤n≤10001 \le n \le 1000)。

接下来有 nn 行。其中第 ii 行包含两个整数 aia_i 和 bib_i(1≤ai,bi≤1051 \le a_i, b_i \le 10^5;∣ai−bi∣≤5|a_i - b_i| \le 5)。

输入的附加约束:aia_i 和 bib_i 的序列永远不会导致某一行的瓷砖数量为非正数。

输出格式

Print one integer — the number of paths from the first row to the last row, taken modulo 998244353998244353.

输出一个整数——从第一行到最后一行的路径数量,对 998244353998244353 取模。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页