#P11616. [PumpkinOI Round 1] 瓦解

    ID: 11018 远端评测题 1200ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学2025O2优化组合数学逆元洛谷比赛

[PumpkinOI Round 1] 瓦解

Background

Time takes the camera away, without thinking. Memories will not let go.

Problem Description

You have an array aa of length nn. Xiao Q wants you to split it into at most mm non-empty consecutive segments, and the numbers in each segment must be strictly increasing. Now Xiao Q wants to know how many splitting plans there are in total. Since the number of plans may be very large, you only need to output the result modulo 998244353998244353.

Input Format

This problem contains multiple test cases.

The first line contains an integer TT, which indicates the number of test cases.

Then follow TT test cases. Each test case is given in the following format:

The first line contains two integers n,mn,m, representing the array length and the segment limit.

The second line contains nn integers a1,a2ana_1,a_2\dots a_n.

Output Format

For each test case, output one line containing one integer, which is the number of plans modulo 998244353998244353.

2
3 2
2 3 1
10 5
7 10 9 23 1 6 7 8 9 20
1
29

Hint

Sample Explanation

  • For the first test case, there is only one plan: [2,3],[1][2,3],[1].

Constraints

This problem uses bundled testdata.

  • Subtask 0 (0 pts): samples.
  • Subtask 1 (10 pts): n10\sum n\le 10.
  • Subtask 2 (20 pts): n1000\sum n\le 1000.
  • Subtask 3 (10 pts): the array itself is guaranteed to be strictly increasing.
  • Subtask 4 (30 pts): n106\sum n\le 10^6.
  • Subtask 5 (30 pts): n107\sum n\le 10^7.

For all testdata, it is guaranteed that 1n107,1mn,1ai1091\le \sum n\le 10^7,1\le m\le n,1\le a_i\le 10^9.

Translated by ChatGPT 5