CF1396D.Rainbow Rectangles
NOI/NOI+/CTSC
通过率:0%
时间限制:4.00s
内存限制:512MB
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×L grid. There are n M&M candies on the grid, the i-th M&M is currently located at (xi+0.5,yi+0.5), and has color ci 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 (X1,Y1) and right-top vertex (X2,Y2) are points with integer coordinates satisfying 0≤X1<X2≤L and 0≤Y1<Y2≤L, so that for every color 1≤c≤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 109+7.
虾米·杜克是一个又胖又贪吃的小男孩,总是饿着肚子。在四处寻找食物以满足他永无止境的饥饿感之后,虾米·杜克发现了一堆无人看管的M&M巧克力豆,它们散落在一个 L×L 的网格上。网格上共有 n 颗M&M巧克力豆,其中第 i 颗位于坐标 (xi+0.5,yi+0.5) 处,颜色为 ci(总共有 k 种不同颜色;M&M豆的尺寸可忽略不计)。
虾米·杜克想偷走一个矩形区域内的所有M&M豆,具体而言,他希望选取一个顶点坐标均为整数的矩形(即该矩形完全位于网格内),并偷走该矩形内部的所有糖果。虾米·杜克并不需要偷走全部糖果,但他希望每种颜色至少偷到一颗。
换言之,他要选取一个边与坐标轴平行的矩形,其左下角顶点为 (X1,Y1)、右上角顶点为 (X2,Y2),且 X1,Y1,X2,Y2 均为整数,并满足 0≤X1<X2≤L 和 0≤Y1<Y2≤L;同时要求对每种颜色 1≤c≤k,该矩形内至少包含一颗颜色为 c 的M&M豆。
问:满足上述条件的矩形有多少个?由于答案可能很大,请输出其对 109+7 取模的结果。
输入格式
The first line contains three positive integers n,k,L (1≤k≤n≤2⋅103,1≤L≤109) — 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 xi,yi,ci (0≤xi,yi<L,1≤ci≤k) — the coordinates and color of the i-th M&M respectively.
Different M&Ms have different coordinates (xi=xj or yi=yj for every i=j), and for every 1≤c≤k there is at least one M&M with color c.
第一行包含三个正整数 n,k,L(1≤k≤n≤2⋅103,1≤L≤109)—— 分别表示 M&M 巧克力豆的数量、颜色种类数以及网格的长度。
接下来的 n 行描述了这些 M&M 巧克力豆。每行包含三个整数 xi,yi,ci(0≤xi,yi<L,1≤ci≤k)—— 分别表示第 i 颗 M&M 巧克力豆的坐标及其颜色。
任意两颗 M&M 巧克力豆的坐标均不相同(即对任意 i=j,均有 xi=xj 或 yi=yj),且对每个 1≤c≤k,至少存在一颗颜色为 c 的 M&M 巧克力豆。
输出格式
Output a single integer — the number of rectangles satisfying Shrimpy Duc's conditions, modulo 109+7.
输出一个整数——满足 Shrimpy Duc 条件的矩形数量,对 109+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:

第一个样例的网格:

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