2021: [USACO 2024 January Contest Gold] Problem 2. Cowmpetency

文件提交:无需freopen 内存限制:256 MB 时间限制:2.000 S
评测方式:普通裁判 命题人:
提交:1 解决:1

题目描述

Farmer John is hiring a new herd leader for his cows. To that end, he has interviewed N (2N109) cows for the position. After each interview, he assigned an integer "cowmpetency" score to the candidate ranging from 1 to C (1C104) that is correlated with their leadership abilities.

Because he has interviewed so many cows, Farmer John has forgotten all of their cowmpetency scores. However, he does remembers Q (1Qmin(N1,100)) pairs of numbers (ai,hi) where cow hi was the first cow with a strictly greater cowmpetency score than cows 1 through ai (so 1ai<hiN).

Farmer John now tells you the Q pairs of (ai,hi). Help him count how many sequences of cowmpetency scores are consistent with this information! It is guaranteed that there is at least one such sequence. Because this number may be very large, output its value modulo 109+7.

输入

The first line contains NQ, and C.

The next Q lines each contain a pair (ai,hi). It is guaranteed that all aj are distinct.

输出

The number of sequences of cowmpetency scores consistent with what Farmer John remembers, modulo 109+7.

样例输入

6 2 3
2 3
4 5

样例输出

6

提示

The following six sequences are the only ones consistent with what Farmer John remembers:

1 1 2 1 3 1

1 1 2 1 3 2

1 1 2 1 3 3

1 1 2 2 3 1

1 1 2 2 3 2

1 1 2 2 3 3

SAMPLE INPUT:

10 1 20

1 3

SAMPLE OUTPUT:

399988086

Make sure to output the answer modulo 109+7.

SCORING:

  • Inputs 3-4 satisfy N10 and Q,C4.
  • Inputs 5-7 satisfy N,C100.
  • Inputs 8-10 satisfy N2000 and C200.
  • Inputs 11-15 satisfy N,C2000.
  • Inputs 16-20 satisfy no additional constraints.

来源/分类