Submit | All submissions | Best solutions | Back to list |
NICEDAY - The day of the competitors |
The International Olympiad in Informatics is coming and the leaders of the Vietnamese Team have to choose the best contestants all over the country. Fortunately, the leaders could choose the members of the team among N very good contestants, numbered from 1 to N (3 ≤ N ≤ 100000). In order to select the best contestants the leaders organized three competitions. Each of the N contestants took part in all three competitions and there were no two contestants with equal results on any of the competitions. We say that contestant А is better than another contestant В when А is ranked before В in all of the competitions. A contestant A is said to be excellent if no other contestant is better than A. The leaders of the Vietnamese Team would like to know the number of excellent contestants.
Input
First line of the input contains an integer t (1 ≤ t ≤ 10), equal to the number of test cases. Then descriptions of t test cases follow. First line of description contains the number of competitors N . Each of the next N lines describes one competitor and contains integer numbers ai, bi, ci (1 ≤ ai, bi, ci ≤ N ) separated by spaces, the order of i-th competitor's ranking in the first competition , the second competition and the third competition.
Output
For each test case in the input your program should output the number of excellent contestants in one line.
Note: Because the input is too large so we have 4 input files and the total time limit is 4s (not 1s).
Example
Input: 1 3 1 2 3 2 3 1 3 1 2 Output: 3
Added by: | Nguyen Minh Hieu |
Date: | 2006-01-20 |
Time limit: | 0.109s |
Source limit: | 10000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | Base on a problem from BOI |
hide comments
|
|||||||
2017-04-18 09:49:48 Medo
**SPOILERS** It is worth checking how to solve this problem by Sweeps even if you solved it using a Tree structure. Last edit: 2017-04-18 09:50:06 |
|||||||
2017-03-27 13:26:25 shubham
This problem will reduced to counting inversion problem after sorting |
|||||||
2017-01-23 17:33:42
if inputs are like this.... 5 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 then what will be the output ? is it 1? Last edit: 2017-01-23 22:12:42 |
|||||||
2016-08-20 17:40:04 Mohammad Asif
The problem statement is horrible and very confusing. I think the problem setter meant sth else.. The way I see it , the answer should be '0'. |
|||||||
2016-04-05 07:12:55 Nguyen Cuong
NKTEAM got 100, TLE here :v UPDATE: got TLE because read input format like NKTEAM :v Last edit: 2016-04-05 07:27:22 |
|||||||
2016-02-16 14:44:43 minhthai
any tips for BIT in java to pass ? |
|||||||
2016-01-04 20:12:42
done with help :(.............. but learnt a lot.....:) |
|||||||
2015-08-19 15:01:58 (Tjandra Satria Gunawan)(曾毅昆)
Awesome problem (^_^) think asymmetrically to solve this :) |
|||||||
2015-03-27 04:02:27 sai krishna
cant understand the qusetion itself can any one please explain |
|||||||
2015-01-31 12:44:34 californiagurl
any tricky testcase? |