#FT0000155. Những điểm nằm trong hình chữ nhật bao (Enclosed Points)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Những điểm nằm trong hình chữ nhật bao (Enclosed Points)
Enclosed Points
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
You are given planar points with pairwise distinct -coordinates and pairwise distinct -coordinates. For every nonempty subset of the point set , form the smallest axis-aligned rectangle containing all points of . Let be the number of points from the entire set inside or on the boundary of this rectangle; these points need not belong to . Compute modulo .
Input
The first line contains . Each of the next lines gives .
Output
Print the required sum modulo .
Subtasks
- Subtask 1 (20 points): ; For all , and ; .
- Subtask 2 (30 points): ; For all , and ; .
- Subtask 3 (50 points): ; For all , and ; .
Examples
Example 1
Input
3
-1 3
2 1
3 -2
Output
13
Explanation
There are seven nonempty subsets. The three singletons each give ; the three pairs give ; the full set gives . Thus the sum is .
Example 2
Input
1
0 0
Output
1
Explanation
Only the singleton subset exists; its degenerate bounding rectangle contains one point, so the sum is 1.