CF1821F.Timber

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There is a beautiful alley with trees in front of a shopping mall. Unfortunately, it has to go to make space for the parking lot.

The trees on the alley all grow in a single line. There are nn spots for trees, index 00 is the shopping mall, index n+1n+1 is the road and indices from 11 to nn are the spots for trees. Some of them are taken — there grow trees of the same height kk. No more than one tree grows in each spot.

When you chop down a tree in the spot xx, you can make it fall either left or right. If it falls to the left, it takes up spots from x−kx-k to xx, inclusive. If it falls to the right, it takes up spots from xx to x+kx+k, inclusive.

Let mm trees on the alley grow in some spots x1,x2,…,xmx_1, x_2, \dots, x_m. Let an alley be called unfortunate if all mm trees can be chopped down in such a way that:

  • no tree falls on the shopping mall or the road;
  • each spot is taken up by no more than one fallen tree.

Calculate the number of different unfortunate alleys with mm trees of height kk. Two alleys are considered different if there is a spot yy such that a tree grows in yy on the first alley and doesn't grow in yy on the second alley.

Output the number modulo 998 244 353998\,244\,353.

一条美丽的林荫道位于一家购物中心前方,但很遗憾,它必须被拆除以腾出空间修建停车场。

林荫道上的所有树木都沿一条直线生长。一共有 nn 个可种植树木的位置,其中位置编号 00 对应购物中心,位置编号 n+1n+1 对应道路,而位置编号 11 至 nn 是可供种植树木的位置。其中某些位置上已种有树木,且所有树木高度均为 kk;每个位置至多有一棵树。

当你在位置 xx 处砍倒一棵树时,可以让它向左或向右倾倒。若向左倾倒,则它将占据从位置 x−kx-k 到 xx(含端点)的所有位置;若向右倾倒,则它将占据从位置 xx 到 x+kx+k(含端点)的所有位置。

设林荫道上有 mm 棵树,分别生长在位置 x1,x2,…,xmx_1, x_2, \dots, x_m 上。若存在一种砍伐方式,使得这 mm 棵树全部被砍倒,并满足以下两个条件,则称该林荫道为“不幸的”(unfortunate):

  • 任何一棵树均不倒向购物中心(位置 00)或道路(位置 n+1n+1);
  • 每个位置至多被一棵倒下的树所占据。

请计算共有多少种不同的“不幸的”林荫道,其中恰好有 mm 棵高度为 kk 的树。若存在某个位置 yy,使得第一条林荫道在 yy 处有树而第二条没有(或反之),则认为这两条林荫道不同。

请输出结果对 998 244 353998\,244\,353 取模的值。

输入格式

The only line contains three integers n,mn, m and kk (1≤m,k≤n≤3⋅1051 \le m, k \le n \le 3 \cdot 10^5) — the number of spots for the trees, the number of trees and the height of each tree.

唯一的一行包含三个整数 n,mn, m 和 kk(1≤m,k≤n≤3⋅1051 \le m, k \le n \le 3 \cdot 10^5)——分别为树的种植位置数量、树的数量以及每棵树的高度。

输出格式

Print a single integer — the number of different unfortunate alleys with mm trees of height kk, modulo 998 244 353998\,244\,353.

输出一个整数——高度为 kk 的含 mm 棵树的不同的不幸小巷的数量,对 998 244 353998\,244\,353 取模。

输入输出样例

  • 输入#1

    6 1 4

    输出#1

    4
  • 输入#2

    5 2 2

    输出#2

    0
  • 输入#3

    6 2 2

    输出#3

    4
  • 输入#4

    15 3 2

    输出#4

    311

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

首页