CF1396D.Rainbow Rectangles

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Shrimpy Duc is a fat and greedy boy who is always hungry. After a while of searching for food to satisfy his never-ending hunger, Shrimpy Duc finds M&M candies lying unguarded on a L×LL \times L grid. There are nn M&M candies on the grid, the ii -th M&M is currently located at (xi+0.5,yi+0.5),(x_i + 0.5, y_i + 0.5), and has color cic_i out of a total of kk colors (the size of M&Ms are insignificant).

Shrimpy Duc wants to steal a rectangle of M&Ms, specifically, he wants to select a rectangle with integer coordinates within the grid and steal all candies within the rectangle. Shrimpy Duc doesn't need to steal every single candy, however, he would like to steal at least one candy for each color.

In other words, he wants to select a rectangle whose sides are parallel to the coordinate axes and whose left-bottom vertex (X1,Y1)(X_1, Y_1) and right-top vertex (X2,Y2)(X_2, Y_2) are points with integer coordinates satisfying 0X1<X2L0 \le X_1 < X_2 \le L and 0Y1<Y2L0 \le Y_1 < Y_2 \le L , so that for every color 1ck1 \le c \le k there is at least one M&M with color cc that lies within that rectangle.

How many such rectangles are there? This number may be large, so you only need to find it modulo 109+710^9 + 7 .

输入格式

The first line contains three positive integers n,k,Ln, k, L (1kn2103,1L109)(1 \leq k \leq n \leq 2 \cdot 10^3, 1 \leq L \leq 10^9 ) — the number of M&Ms, the number of colors and the length of the grid respectively.

The following nn points describe the M&Ms. Each line contains three integers xi,yi,cix_i, y_i, c_i (0xi,yi<L,1cik)(0 \leq x_i, y_i < L, 1 \le c_i \le k) — the coordinates and color of the ii -th M&M respectively.

Different M&Ms have different coordinates ( xixjx_i \ne x_j or yiyjy_i \ne y_j for every iji \ne j ), and for every 1ck1 \le c \le k there is at least one M&M with color cc .

输出格式

Output a single integer — the number of rectangles satisfying Shrimpy Duc's conditions, modulo 109+710^9 + 7 .

输入输出样例

  • 输入#1

    4 2 4
    3 2 2
    3 1 1
    1 1 1
    1 2 1

    输出#1

    20
  • 输入#2

    5 3 10
    6 5 3
    5 3 1
    7 9 1
    2 3 2
    5 0 2

    输出#2

    300
  • 输入#3

    10 4 10
    5 4 4
    0 0 3
    6 0 1
    3 9 2
    8 7 1
    8 1 3
    2 1 3
    6 3 2
    3 5 3
    4 3 4

    输出#3

    226

说明/提示

Grid for the first sample:

首页