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 n spots for trees, index 0 is the shopping mall, index n+1 is the road and indices from 1 to n are the spots for trees. Some of them are taken — there grow trees of the same height k. No more than one tree grows in each spot.
When you chop down a tree in the spot x, you can make it fall either left or right. If it falls to the left, it takes up spots from x−k to x, inclusive. If it falls to the right, it takes up spots from x to x+k, inclusive.
Let m trees on the alley grow in some spots x1,x2,…,xm. Let an alley be called unfortunate if all m 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 m trees of height k. Two alleys are considered different if there is a spot y such that a tree grows in y on the first alley and doesn't grow in y on the second alley.
Output the number modulo 998244353.
一条美丽的林荫道位于一家购物中心前方,但很遗憾,它必须被拆除以腾出空间修建停车场。
林荫道上的所有树木都沿一条直线生长。一共有 n 个可种植树木的位置,其中位置编号 0 对应购物中心,位置编号 n+1 对应道路,而位置编号 1 至 n 是可供种植树木的位置。其中某些位置上已种有树木,且所有树木高度均为 k;每个位置至多有一棵树。
当你在位置 x 处砍倒一棵树时,可以让它向左或向右倾倒。若向左倾倒,则它将占据从位置 x−k 到 x(含端点)的所有位置;若向右倾倒,则它将占据从位置 x 到 x+k(含端点)的所有位置。
设林荫道上有 m 棵树,分别生长在位置 x1,x2,…,xm 上。若存在一种砍伐方式,使得这 m 棵树全部被砍倒,并满足以下两个条件,则称该林荫道为“不幸的”(unfortunate):
- 任何一棵树均不倒向购物中心(位置 0)或道路(位置 n+1);
- 每个位置至多被一棵倒下的树所占据。
请计算共有多少种不同的“不幸的”林荫道,其中恰好有 m 棵高度为 k 的树。若存在某个位置 y,使得第一条林荫道在 y 处有树而第二条没有(或反之),则认为这两条林荫道不同。
请输出结果对 998244353 取模的值。
输入格式
The only line contains three integers n,m and k (1≤m,k≤n≤3⋅105) — the number of spots for the trees, the number of trees and the height of each tree.
唯一的一行包含三个整数 n,m 和 k(1≤m,k≤n≤3⋅105)——分别为树的种植位置数量、树的数量以及每棵树的高度。
输出格式
Print a single integer — the number of different unfortunate alleys with m trees of height k, modulo 998244353.
输出一个整数——高度为 k 的含 m 棵树的不同的不幸小巷的数量,对 998244353 取模。
输入输出样例
输入#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测评打分。不知道怎么写?