QOJ.ac

QOJ

时间限制: 2 s 内存限制: 2048 MB 总分: 100

#21566. 4D Partial Order

统计

In the four-dimensional Cartesian coordinate system $Oxyzw$, there are $n$ points $P(x, y, z, w)$. You need to count how many pairs of points $P_i, P_j$ satisfy:

  • $x_i < x_j$
  • $y_i < y_j$
  • $z_i < z_j$
  • $w_i < w_j$

Input

The first line of input contains an integer $n$.

The next $n$ lines each contain $4$ integers $x, y, z, w$, representing the coordinates of the $i$-th point $P_i(x, y, z, w)$.

Output

Output a single integer representing the answer.

Subtasks

For all data, it is guaranteed that $x_i, y_i, z_i, w_i \in [1, n]$, no two points have the same coordinate in any dimension, and $1 \leq n \leq 10^5$.

Examples

Input 1

6
2 1 4 1
5 6 6 5 
3 3 3 4
6 4 5 6
4 5 2 3 
1 2 1 2

Output 1

9

Input 2

15
13 1 2 3
2 2 13 11
10 10 7 2
3 6 14 14
1 12 9 15
12 14 8 8
8 13 15 5
4 8 12 10
5 3 1 4
7 5 11 1
9 11 6 13
6 15 10 9
15 9 5 12
14 4 4 6
11 7 3 7

Output 2

15

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.