Excellent Engineers
Time limit3sMemory limit256 MB
Count the engineers no rival beats in all three skill ranks for each test case.
- Level
Medium6 of 10
- Topics
- Sorting, Segment tree
- Solved
- No attempts yet
Problem
You work for an agency that places the best software engineers from Belgium, the Netherlands and Luxembourg with companies around the world. The files hold so many strong engineers that the agency asked you to build a tool that picks the most promising candidates quickly.
Every engineer is tested extensively before entering the files. The tests rank all engineers on three skills: communication skills, programming skills, and algorithmic knowledge. The engineer with rank one in algorithmic knowledge is the best algorithmic expert in the files, rank two is the second best, and so on.
The tool has to produce a shortlist of the candidates a customer might want. An engineer goes on the shortlist if no other engineer in the files scores better on all three skills at once. That is, an engineer goes on the list unless some other engineer has better communication skills, better programming skills, and more algorithmic knowledge.
Input
The first line holds one positive integer, the number of test cases, which is at most 100. Each test case is given as follows.
- One line with a single integer (), the number of engineers in the files.
- lines, each with three space separated integers , and (): the rank of that engineer in communication skills, programming skills and algorithmic knowledge, in that order.
For each skill and each rank between 1 and , exactly one engineer has that rank.
Output
For each test case, print one line with a single integer, the number of candidates on the shortlist.
