mulitset可以当BST用。。。
Efficient Solutions
[Submit] [Go Back] [Status] Description Problem I Output: Standard Output
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 decision. She rates the lad 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 the scores LA and CA (for lineage and charm, respectively). B receives scores LB and CB. Then A is dominated by B if either
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 be efficient (or Pareto-optimal) if she has not yet met any other gentleman who dominates him. She maintains a list of efficient grooms and 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 in the list of efficient grooms after each performance. Input Each one starts with a line containing n (0≤n≤15000) - the size of the queue. The next n lines will each contain two scores (integers in the range [0, 109]). Initially, the list is empty. Output
Problemsetter: Igor Naverniouk
Warming: The judge input file size is about 1.2 MB. [Submit] [Go Back] [Status] |
![]() |
#include#include #include #include #include using namespace std; struct POINT { int x, y; bool operator<(const POINT res) const { if (x != res.x) { return x < res.x; } else { return y < res.y; } } }P; int main() { multiset msp; multiset ::iterator it; int t,n,cas=1; scanf("%d",&t); while(t--) { msp.clear(); scanf("%d",&n); if(cas>1) putchar(10); printf("Case #%d:\n",cas++); for(int i=0;i y>b) { msp.insert(P); it=msp.upper_bound(P); while(it!=msp.end()&&it->y>=b) { msp.erase(it++); } } printf("%d\n",msp.size()); } } return 0; }
