Title: http://uva.onlinejudge.org/external/110/11020.pdf
Problem IEfficient Solutions
Input: Standard Input
Output: standard output
"Our marriage ceremonies are solemn, sober Moments of reflection; also regret, disagreement, Argument and mutual recrimination. Once you know It can't get any worse, you can relax and enjoy The marriage ." |
J. Michael straczynski, "the deconstruction of falling stars ."
The Princess of Centauri Prime is the galaxy's most eligible bachelorette Of The Year. she has hopeful grooms lined up in front of the royal palace for a chance to spend 5 minutes to try and impress her. after 5 minutes, the gentleman is carried out of the royal chambers by the palace guards, and the princess makes a demo. she rates the glad on his lineage and charm by giving him a score for each of the two properties. on Centauri Prime, low scores are better than high scores.
Suppose that she observes two gentlemen-A and B. She assigns a scores la and Ca (for lineage and charm, respectively). B receives scores lb and CB. Then a isDominatedBy B if either
- LB <la and CB <= Ca, or
- LB <= La and CB <ca.
In other words, if at least one of B's scores is better than a's, and the other score is not worse. She considers a gentleman to beEfficient(Or Pareto-optimal) if she has not yet met any other gentleman who dominates him. She maintainsList of efficient groomsAnd updates it after each 5-minute presentation.
Given the queue of bachelors and the scores assigned to them by the princess, determine the number of entries inList of efficient groomsAfter each performance.
Input
The first line of input gives the number of cases,N (0 <n <40).NTest Cases follow.
Each one starts with a line iningN(0 ≤N≤ 15000)-the size of the queue. The nextNLines will each contain two scores (integers in the range [0,109]). Initially, the list is empty.
Output
For each test case, output one line containing "case #X: "FollowedNLines, line I containing the size ofList of efficient groomsAfter the ithupdate. Print an empty line between test cases.
Sample Input |
Sample output |
4 1 100 200 2 100 200 101 202 2 100 200 200 100 5 11 20 20 10 20 10 100 20 1 1 |
Case #1: 1 Case #2: 1 1 Case #3: 1 2 Case #4: 1 2 3 3 1 |
Problemsetter: Igor naverniouk
Special thanks: Yury kholondyrev
Warming: The judge input file size is about 1.2 MB.
Practice: STL is amazing .. I learned some usage of set and Multiset. This problem is maintained by Multiset. It is very bare and I will learn treap soon ..