QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#12878. 狮子王

Statistics

在非洲的荣耀大地(Pride Lands)上,狮子作为万兽之王统治着这片土地。木法沙国王(King Mufasa)和沙拉比王后(Queen Sarabi)的儿子辛巴(Simba)的诞生,引起了木法沙的弟弟刀疤(Scar)的嫉妒和怨恨,刀疤深知这个侄子现在取代了他成为王位继承人。

在辛巴长成一只幼狮后,木法沙带他游览了荣耀大地,教导他作为国王的责任以及生生不息的循环(circle of life)。他们整天都在游览,现在是睡觉的时间了。

由于辛巴还小,他没能很快入睡,并不停地推搡他的父亲想和他说话。木法沙非常疲惫,想睡觉,于是他想出了一个难题来让辛巴忙碌起来。木法沙问辛巴天上有多少颗星星?

辛巴看到天空中是一个无限的二维网格,上面有一些发光的点。

一颗星星是由五个点 $(p_1, p_2, p_3, p_4, p_5)$ 组成的集合,满足以下条件:

  • $p_1.y > p_5.y$
  • $p_5.y = p_2.y$
  • $p_3.y, p_4.y < p_5.y$
  • $p_5.x < p_1.x < p_2.x$
  • $p_5.x < p_4.x < p_1.x$
  • $p_1.x < p_3.x < p_2.x$

你能帮辛巴尽快回答这个问题吗?

输入格式

你的程序将在一个或多个测试用例上进行测试。输入的第一行是一个整数 $T$ ($1 \le T \le 200$),表示测试用例的数量。每个测试用例的第一行包含一个整数 $N$ ($5 \le N \le 5,000$),表示天空中点的数量。

接下来的 $N$ 行,每行包含一对整数 $x$ 和 $y$($-5,000 \le x, y \le 5,000$),表示点的坐标。

输出格式

对于每个测试用例,输出辛巴在天空中能看到的星星数量,结果对 $1,000,000,007$ 取模。每个点可以属于多颗星星。

样例

输入 1

2
5
0 5
4 4
-4 4
2 0
-2 0
8
0 5
4 4
-6 4
2 0
-1 0
-5 4
0 12
3 0

输出 1

1
8

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.