CF1190D.Tokitsukaze and Strange Rectangle

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There are nn points on the plane, the ii-th of which is at (xi,yi)(x_i, y_i). Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area.

The strange area is enclosed by three lines, x=lx = l, y=ay = a and x=rx = r, as its left side, its bottom side and its right side respectively, where ll, rr and aa can be any real numbers satisfying that l<rl \lt r. The upper side of the area is boundless, which you can regard as a line parallel to the xx-axis at infinity. The following figure shows a strange rectangular area.

A point (xi,yi)(x_i, y_i) is in the strange rectangular area if and only if l<xi<rl \lt x_i \lt r and yi>ay_i \gt a. For example, in the above figure, p1p_1 is in the area while p2p_2 is not.

Tokitsukaze wants to know how many different non-empty sets she can obtain by picking all the points in a strange rectangular area, where we think two sets are different if there exists at least one point in one set of them but not in the other.

平面上有 nn 个点,其中第 ii 个点的坐标为 (xi,yi)(x_i, y_i)。Tokitsukaze 想画出一个特殊的矩形区域,并选取该区域内所有的点。

该特殊区域由三条直线 x=lx = l、y=ay = a 和 x=rx = r 围成,分别作为其左侧边、底边和右侧边,其中 ll、rr 和 aa 可取任意满足 l<rl \lt r 的实数。该区域的上边界无界,可视为一条在无穷远处、平行于 xx 轴的直线。下图展示了一个这样的特殊矩形区域。

当且仅当 l<xi<rl \lt x_i \lt r 且 yi>ay_i \gt a 时,点 (xi,yi)(x_i, y_i) 位于该特殊矩形区域内。例如,在上图中,p1p_1 在该区域内,而 p2p_2 不在。

Tokitsukaze 想知道:通过选取某个特殊矩形区域内的所有点,她最多能得到多少个互不相同的非空点集?这里认为两个点集不同,当且仅当其中至少有一个点属于其中一个集合但不属于另一个集合。

输入格式

The first line contains a single integer nn (1≤n≤2×1051 \leq n \leq 2 \times 10^5) — the number of points on the plane.

The ii-th of the next nn lines contains two integers xix_i, yiy_i (1≤xi,yi≤1091 \leq x_i, y_i \leq 10^9) — the coordinates of the ii-th point.

All points are distinct.

第一行包含一个整数 nn(1≤n≤2×1051 \leq n \leq 2 \times 10^5)—— 表示平面上的点的数量。

接下来的 nn 行中,第 ii 行包含两个整数 xix_i、yiy_i(1≤xi,yi≤1091 \leq x_i, y_i \leq 10^9)—— 表示第 ii 个点的坐标。

所有点互不相同。

输出格式

Print a single integer — the number of different non-empty sets of points she can obtain.

输出一个整数——她能得到的不同非空点集的个数。

输入输出样例

  • 输入#1

    3
    1 1
    1 2
    1 3

    输出#1

    3
  • 输入#2

    3
    1 1
    2 1
    3 1

    输出#2

    6
  • 输入#3

    4
    2 1
    2 2
    3 1
    3 2

    输出#3

    6

说明/提示

For the first example, there is exactly one set having kk points for k=1,2,3k = 1, 2, 3, so the total number is 33.

For the second example, the numbers of sets having kk points for k=1,2,3k = 1, 2, 3 are 33, 22, 11 respectively, and their sum is 66.

For the third example, as the following figure shows, there are

  • 22 sets having one point;
  • 33 sets having two points;
  • 11 set having four points.

Therefore, the number of different non-empty sets in this example is 2+3+0+1=62 + 3 + 0 + 1 = 6.

第一个样例中,恰好存在一个包含 kk 个点的集合,其中 k=1,2,3k = 1, 2, 3,因此总数为 33。

第二个样例中,包含 kk 个点的集合的数量(k=1,2,3k = 1, 2, 3)分别为 33、22、11,其总和为 66。

第三个样例中,如下图所示,存在:

  • 22 个仅含一个点的集合;
  • 33 个含有两个点的集合;
  • 11 个含有四个点的集合。

因此,本样例中不同的非空集合数量为 2+3+0+1=62 + 3 + 0 + 1 = 6。

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

首页