Codeforces Round 666 (Div. 1)
D
Rainbow Rectangles
Codeforces
3300
原题
← CE →
翻译中…

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 \times L$ grid. There are $n$ M&M candies on the grid, the $i$-th M&M is currently located at $(x_i + 0.5, y_i + 0.5),$ and has color $c_i$ out of a total of $k$ 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 $(X_1, Y_1)$ and right-top vertex $(X_2, Y_2)$ are points with integer coordinates satisfying $0 \le X_1 \lt X_2 \le L$ and $0 \le Y_1 \lt Y_2 \le L$, so that for every color $1 \le c \le k$ there is at least one M&M with color $c$ that lies within that rectangle.

翻译中…

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

翻译中…

Input

翻译中…

The first line contains three positive integers $n, k, L$ $(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 $n$ points describe the M&Ms. Each line contains three integers $x_i, y_i, c_i$ $(0 \leq x_i, y_i \lt L, 1 \le c_i \le k)$ — the coordinates and color of the $i$-th M&M respectively.

翻译中…

Different M&Ms have different coordinates ($x_i \ne x_j$ or $y_i \ne y_j$ for every $i \ne j$), and for every $1 \le c \le k$ there is at least one M&M with color $c$.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

Grid for the first sample:

翻译中…

image

翻译中…

样例

Input #1
4 2 4
3 2 2
3 1 1
1 1 1
1 2 1
Output #1
20
InputCopy OutputCopy
Input #2
5 3 10
6 5 3
5 3 1
7 9 1
2 3 2
5 0 2
Output #2
300
InputCopy OutputCopy
Input #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
Output #3
226
InputCopy OutputCopy
题目信息
题号
1396D
时间限制
4 s
内存限制
512 MB
标签
数据结构
排序
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。