QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 512 MB Puntuación total: 100

#415. 王的象棋世界

Estadísticas

$R\times C$ のチェス盤がある。$Q$ 個のクエリが与えられる。各クエリでは、キングが $(1,a)$ から $(R,b)$ まで $R-1$ 手で移動する方法が何通りあるかを求める。答えを $998244353$ で割った余りを出力せよ。

入力

1行目に3つの正整数 $R, C, Q$ が与えられる。これらはチェス盤の縦横のサイズとクエリの回数を表す。

続く $Q$ 行の各行には、2つの正整数 $a, b$ が与えられる。これは各クエリの始点と終点の列を表す。

出力

$Q$ 行にわたって、各クエリに対する移動方法の数を整数で出力せよ。

入出力例

入力 1

13 10 10
10 1
2 2
9 1
10 5
8 8
9 1
9 3
7 5
5 6
8 10

出力 1

328
45475
1142
12804
65715
1142
7995
58199
69552
29964

小課題

すべてのデータにおいて、$2\le C\le 10^5, C\le R\le 10^9, 1\le Q\le 10^5$ を満たす。

子課題番号 $C\le$ $Q\le $ 配点
$1$ $10^2$ $10^4$ $11$
$2$ $10^3$ $10$ $14$
$3$ $10^5$ $25$
$4$ $10^5$ $10^2$ $30$
$5$ $10^5$ $20$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.