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
|
|||||||
2015-01-26 19:13:55 S
only BIT .. learnt a lot seriously .. :D |
|||||||
2014-09-24 10:28:47 Anowar Hossain Anu
BIT |
|||||||
2014-05-16 21:25:54 Luis Manuel D�az Bar�n
the problem statement is awful it should be corrected, I needed to read comments to realize what it really means. |
|||||||
2013-12-09 20:37:35 aristofanis
Getting 100 in NKTEAM and WA here, whats wrong? |
|||||||
2012-05-27 05:11:39 Anand
if you think of the last condition, solution is on its way. |
|||||||
2011-10-30 08:07:49 つ ◕_◕ ༽つ GIFF AC
@Akashs you're wrong. A is not excellent constestant if there exists 1 another constestant B score higher than A in ALL 3 competitions. A=excellent constestant if A!=not excellent constestant. Read the example again you'll see that the answer is 3. |
|||||||
2011-10-02 14:28:45 Md. M. I. Akashs
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." in terms of this statement in the problem the result of the test case given in the problem should be 0. because in the first competition first contestant is better than all other contestant. In second competition third contestant is better than all other contestant. In third competition second contestant is better than all other contestant so result should be 0. Am i right ? |
|||||||
2011-07-10 21:45:01 Carlos Joa
@problem setter: I'd like to add a test case to this proble. How can I contact you? |
|||||||
2011-07-03 02:20:09 Vladimir Kirichenkoff
Read the definitions carefully: a contestant A is excellent if no other contestant is better than A. Look at first contestant. The second contestant isn't better than the first and the third contestant isn't better than the first so the first contestant is excellent. And for other contestant written above is corrent so the answer for the testcase is 3, not 0 Last edit: 2011-07-03 02:20:46 |
|||||||
2011-06-12 18:08:10 Santiago Palacio
There was no better candidate, all of them are at the same rank. (1 is not better than 1) |