#FT0000159. Ada và các giống rau (Ada and Species)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Ada và các giống rau (Ada and Species)
Ada and Species
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Ada has vegetable species, each with four attributes ; smaller values are better. Species is worse than species exactly when all four attributes of are strictly larger: , , , and . Ada removes any species that is worse than at least one other species. Count how many remain. Each attribute column is independently a permutation of , so all strict inequalities have no ties.
Input
The first line contains . Each of the next lines gives the four attributes of a species.
Output
Print one integer: the number of species that are not removed.
Subtasks
- Subtask 1 (20 points): ; Each coordinate lies in , and each of the four coordinate columns is separately a permutation of (no ties).
- Subtask 2 (30 points): ; Each coordinate lies in , and each of the four coordinate columns is separately a permutation of (no ties).
- Subtask 3 (50 points): ; Each coordinate lies in , and each of the four coordinate columns is separately a permutation of (no ties).
Examples
Example 1
Input
3
1 1 1 1
2 2 2 2
3 3 3 3
Output
1
Explanation
The first species has smaller values in all four attributes than species 2 and 3, so both are removed; the first remains. Answer: 1.
Example 2
Input
4
1 4 1 4
2 3 2 3
3 2 3 2
4 1 4 1
Output
4
Explanation
Whenever one species has a smaller , it has a larger . Thus no species is strictly better than another in all four attributes, and all four remain.