#P6144. [USACO20FEB] Help Yourself P

    ID: 6936 远端评测题 2000ms 250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划 DP2020线段树USACOStirling 数

[USACO20FEB] Help Yourself P

Problem Description

There are NN line segments on a number line. The ii-th segment covers all real numbers from lil_i to rir_i (including lil_i and rir_i).

Define the union of several segments as the set containing all points that are covered by at least one segment.

Define the complexity of several segments as the KK-th power of the number of connected components in the union of these segments.

Now Bessie wants to compute, among all subsets of the given NN segments (there are 2N2^N subsets in total), the sum of their complexities modulo 109+710^9+7.

You might think you need to help Bessie solve this problem. Unfortunately, you guessed wrong! In this problem, you are Bessie, and no one will help you. You are on your own.

Input Format

The first line contains two integers NN and KK (1N1051 \leq N \leq 10^5; 2K102 \leq K \leq 10).

The next NN lines each contain two integers li,ril_i, r_i, describing a segment. It is guaranteed that 1li<ri2N1 \leq l_i \lt r_i \leq 2N, and no two endpoints are at the same position.

Output Format

Output the required answer modulo 109+710^9+7.

3 2
1 6
2 3
4 5
10

Hint

Sample Explanation

The complexities of all non-empty subsets are as follows (clearly, the complexity of the empty set is zero):

$$\{[1,6]\} \implies 1, \{[2,3]\} \implies 1, \{[4,5]\} \implies 1$$$$\{[1,6],[2,3]\} \implies 1, \{[1,6],[4,5]\} \implies 1, \{[2,3],[4,5]\} \implies 4$${[1,6],[2,3],[4,5]}    1\{[1,6],[2,3],[4,5]\} \implies 1

Therefore, the answer is 1+1+1+1+1+4+1=101+1+1+1+1+4+1=10.

Subtasks

  • Test point 22 satisfies N16N \leq 16.
  • Test points 353 \sim 5 satisfy N103N \leq 10^3 and K=2K=2.
  • Test points 686 \sim 8 satisfy N103N \leq 10^3.
  • For test point TT (T[9,16]T \in [9,16]), K=3+(T9)K=3+(T-9).

Translated by ChatGPT 5