Pareto domination
A point with coordinates (x1, x2, …, xn) is called dominated in Pareto’s sense by a point with coordinates (y1, y2, …, yn), if for each i (1 ≤ i ≤ n) the inequality xi ≤ yi holds. A set of some points is given. Your task is to find the number of points in this set, that are not dominated in Pareto’s sense by any other point in the given set.
Specifications
Input
First line of input contains the quantity of tests T (1 ≤ T ≤ 10). First line of each test case contains two numbers: N (1 ≤ N ≤ 50000) – the number of points in the set and M (1 ≤ M ≤ 4) – the space dimension. Then there are N lines, each of which contains M integers – coordinates of a point, separated by spaces (each coordinate is less than 109 by its absolute value). All points in the set are different.
Output
Output T lines of the form "Case #A: B", where A is the number of test (beginning from 1), B is the quantity of non-dominated points.
Problem information
Time Limit: 10 secondsMemory Limit: 64 MB
Balls for the passed test: 20
Complexity: 95% 1/22
Example
Example input2 4 1 1 2 3 4 4 2 0 0 1 1 2 0 0 2 |
Example outputCase #1: 1 Case #2: 3 |
| ← Lines | Problems | Permutations with given distance → |
