CF1833F.Ira and Flamenco

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Ira loves Spanish flamenco dance very much. She decided to start her own dance studio and found nn students, iith of whom has level aia_i.

Ira can choose several of her students and set a dance with them. So she can set a huge number of dances, but she is only interested in magnificent dances. The dance is called magnificent if the following is true:

  • exactly mm students participate in the dance;
  • levels of all dancers are pairwise distinct;
  • levels of every two dancers have an absolute difference strictly less than mm.

For example, if m=3m = 3 and a=[4,2,2,3,6]a = [4, 2, 2, 3, 6], the following dances are magnificent (students participating in the dance are highlighted in red): [4,2,2,3,6][\color{red}{4}, 2, \color{red}{2}, \color{red}{3}, 6], [4,2,2,3,6][\color{red}{4}, \color{red}{2}, 2, \color{red}{3}, 6]. At the same time dances [4,2,2,3,6][\color{red}{4}, 2, 2, \color{red}{3}, 6], [4,2,2,3,6][4, \color{red}{2}, \color{red}{2}, \color{red}{3}, 6], [4,2,2,3,6][\color{red}{4}, 2, 2, \color{red}{3}, \color{red}{6}] are not magnificent.

In the dance [4,2,2,3,6][\color{red}{4}, 2, 2, \color{red}{3}, 6] only 22 students participate, although m=3m = 3.

The dance [4,2,2,3,6][4, \color{red}{2}, \color{red}{2}, \color{red}{3}, 6] involves students with levels 22 and 22, although levels of all dancers must be pairwise distinct.

In the dance [4,2,2,3,6][\color{red}{4}, 2, 2, \color{red}{3}, \color{red}{6}] students with levels 33 and 66 participate, but ∣3−6∣=3|3 - 6| = 3, although m=3m = 3.

Help Ira count the number of magnificent dances that she can set. Since this number can be very large, count it modulo 109+710^9 + 7. Two dances are considered different if the sets of students participating in them are different.

伊菈非常热爱西班牙弗拉门戈舞蹈。她决定创办自己的舞蹈工作室,并找到了 nn 名学生,其中第 ii 名学生的舞蹈水平为 aia_i。

伊菈可以选择她的一些学生来编排一支舞蹈。因此,她可以编排出大量不同的舞蹈,但她只对“辉煌舞蹈”(magnificent dance)感兴趣。一支舞蹈被称为“辉煌舞蹈”,当且仅当满足以下全部条件:

  • 恰好有 mm 名学生参与该舞蹈;
  • 所有舞者的水平两两互不相同;
  • 任意两名舞者的水平之差的绝对值严格小于 mm。

例如,若 m=3m = 3,且 a=[4,2,2,3,6]a = [4, 2, 2, 3, 6],则以下舞蹈是辉煌舞蹈(参与舞蹈的学生以红色高亮显示):[4,2,2,3,6][\color{red}{4}, 2, \color{red}{2}, \color{red}{3}, 6]、[4,2,2,3,6][\color{red}{4}, \color{red}{2}, 2, \color{red}{3}, 6]。而以下舞蹈则不是辉煌舞蹈:[4,2,2,3,6][\color{red}{4}, 2, 2, \color{red}{3}, 6]、[4,2,2,3,6][4, \color{red}{2}, \color{red}{2}, \color{red}{3}, 6]、[4,2,2,3,6][\color{red}{4}, 2, 2, \color{red}{3}, \color{red}{6}]。

在舞蹈 [4,2,2,3,6][\color{red}{4}, 2, 2, \color{red}{3}, 6] 中,仅有 22 名学生参与,但要求 m=3m = 3。

舞蹈 [4,2,2,3,6][4, \color{red}{2}, \color{red}{2}, \color{red}{3}, 6] 中包含了两名水平均为 22 的学生,但所有舞者水平必须两两互不相同。

舞蹈 [4,2,2,3,6][\color{red}{4}, 2, 2, \color{red}{3}, \color{red}{6}] 中包含了水平为 33 和 66 的学生,但 ∣3−6∣=3|3 - 6| = 3,而要求该差值严格小于 m=3m = 3。

请帮助伊菈计算她能编排的辉煌舞蹈的数量。由于该数量可能非常大,请对 109+710^9 + 7 取模输出结果。若两支舞蹈所包含的学生集合不同,则视为不同的舞蹈。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — number of testcases.

The first line of each testcase contains integers nn and mm (1≤m≤n≤2⋅1051 \le m \le n \le 2 \cdot 10^5) — the number of Ira students and the number of dancers in the magnificent dance.

The second line of each testcase contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9) — levels of students.

It is guaranteed that the sum of nn over all testcases does not exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

每个测试用例的第一行包含两个整数 nn 和 mm(1≤m≤n≤2⋅1051 \le m \le n \le 2 \cdot 10^5)—— 分别表示伊菈的学生人数和盛大舞蹈中的舞者人数。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \le a_i \le 10^9)—— 表示各位学生的水平。

保证所有测试用例的 nn 值之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each testcase, print a single integer — the number of magnificent dances. Since this number can be very large, print it modulo 109+710^9 + 7.

对于每个测试用例,输出一个整数——壮丽舞蹈的数量。由于该数可能非常大,请对 109+710^9 + 7 取模后输出。

输入输出样例

  • 输入#1

    9
    7 4
    8 10 10 9 6 11 7
    5 3
    4 2 2 3 6
    8 2
    1 5 2 2 3 1 3 3
    3 3
    3 3 3
    5 1
    3 4 3 10 7
    12 3
    5 2 1 1 4 3 5 5 5 2 7 5
    1 1
    1
    3 2
    1 2 3
    2 2
    1 2

    输出#1

    5
    2
    10
    0
    5
    11
    1
    2
    1

说明/提示

In the first testcase, Ira can set such magnificent dances: [8,10,10,9,6,11,7][\color{red}{8}, 10, 10, \color{red}{9}, \color{red}{6}, 11, \color{red}{7}], [8,10,10,9,6,11,7][\color{red}{8}, \color{red}{10}, 10, \color{red}{9}, 6, 11, \color{red}{7}], [8,10,10,9,6,11,7][\color{red}{8}, 10, \color{red}{10}, \color{red}{9}, 6, 11, \color{red}{7}], [8,10,10,9,6,11,7][\color{red}{8}, 10, \color{red}{10}, \color{red}{9}, 6, \color{red}{11}, 7], [8,10,10,9,6,11,7][\color{red}{8}, \color{red}{10}, 10, \color{red}{9}, 6, \color{red}{11}, 7].

The second testcase is explained in the statements.

在第一个测试用例中,Ira 可以设置如下精彩的舞蹈序列:[8,10,10,9,6,11,7][\color{red}{8}, 10, 10, \color{red}{9}, \color{red}{6}, 11, \color{red}{7}]、[8,10,10,9,6,11,7][\color{red}{8}, \color{red}{10}, 10, \color{red}{9}, 6, 11, \color{red}{7}]、[8,10,10,9,6,11,7][\color{red}{8}, 10, \color{red}{10}, \color{red}{9}, 6, 11, \color{red}{7}]、[8,10,10,9,6,11,7][\color{red}{8}, 10, \color{red}{10}, \color{red}{9}, 6, \color{red}{11}, 7]、[8,10,10,9,6,11,7][\color{red}{8}, \color{red}{10}, 10, \color{red}{9}, 6, \color{red}{11}, 7]。

第二个测试用例已在题目描述中说明。

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

首页