`
20386053
  • 浏览: 461427 次
文章分类
社区版块
存档分类
最新评论

UVA 11020 Efficient Solutions

 
阅读更多



mulitset可以当BST用。。。

Time Limit:3000MS Memory Limit:Unknown 64bit IO Format:%lld & %llu

[Submit] [Go Back] [Status]

Description

Download as PDF

Problem I
Efficient 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. MichaelStraczynski, "The Deconstruction of Falling Stars."

The princess of Centauri Prime is the galaxy's most eligiblebacheloretteof 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 LAand CA(for lineage and charm, respectively). B receives scores LBand CB. Then A isdominatedby B if either

  • LB< LAand CB<= CA, or
  • LB<= LAand 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 maintains alist 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 in thelist of efficient groomsafter each performance.

Input
Thefirst line of input gives the number of cases,N (0<N<40).Ntest cases follow.

Each one starts with a line containingn(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:" followed bynlines, lineicontaining the size of thelist of efficient groomsafter theithupdate. 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: IgorNaverniouk
Special Thanks:YuryKholondyrev

Warming: The judge input file size is about 1.2 MB.

[Submit] [Go Back] [Status]


#include <iostream>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>

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<POINT> msp;
    multiset<POINT>::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<n;i++)
        {
            int a,b;
            scanf("%d%d",&a,&b);
            P=(POINT){a,b};
            it=msp.lower_bound(P);
            if(it==msp.begin()||(--it)->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;
}



分享到:
评论

相关推荐

    Algorithm-UVA-Solutions-in-Python.zip

    "Algorithm-UVA-Solutions-in-Python.zip"这个压缩包文件正是针对UVA竞赛中问题的Python 3解决方案集合。 Python作为一门易学且功能强大的编程语言,因其简洁的语法和丰富的库支持,成为了许多算法爱好者和开发者的...

    开源项目-codingsince1985-UVa#uva-online-judge-solutions-in-golang.zip

    开源项目-codingsince1985-UVa#uva-online-judge-solutions-in-golang.zip,两年来每天都在解决一个uva在线裁判问题,算起来…

    uva272 uva272 uva272

    标题中的"uva272 uva272 uva272"和描述中的"uva272"指的是UVA(University of Virginia)在线判题系统的第272题,这通常与编程竞赛和算法挑战有关。该题目的标签为"算法",意味着我们需要解决一个与计算机算法设计和...

    uvaoj 习题题目

    【uvaoj 习题题目】相关知识点详解 在编程学习和竞赛中,UVa Online Judge(简称UVa或OJ)是一个广受欢迎的在线评测系统,它为程序员提供了大量练习题目,涵盖算法、数据结构、数学等多个领域。通过解决这些题目,...

    UVA-Solutions:UVA解决方案

    《UVA解决方案:Java编程实践指南》 在编程竞赛领域,UVA(University of ...此外,这个UVA-Solutions-master文件夹可能包含了源代码、测试用例、运行脚本等,这些都有助于我们更全面地理解和学习每个问题的解决方案。

    UVA_示例代码

    【UVA在线判题系统与示例代码详解】 UVA(University of Victoria Algorithm Competition)是全球知名的在线算法竞赛平台,它提供了丰富的编程题目供程序员挑战,以提高算法设计和编程能力。UVA Online Judge(简称...

    UVA题目大全

    【UVA题目大全】是面向ACM(国际大学生程序设计竞赛)参赛者和算法爱好者的一份宝贵资源。UVA(University of Victoria Algorithm)在线判题系统是世界上最早的在线编程竞赛平台之一,它提供了大量的编程题目供用户...

    uva最全ac代码

    【标题】"uva最全ac代码" 涉及的是在编程竞赛领域中的一个集锦,特别是针对UVA(University of Victoria Algorithm)在线判题系统的解决方案。UVA是全球最早的在线算法竞赛平台之一,吸引了众多程序员参与并提交代码...

    uva 200~299 22道题解 均accept

    这些文件是针对UVA(University of Virginia)在线判题系统的编程题目的解决方案,主要涵盖了编号为200至299的题目。UVA在线判题平台是一个著名的编程竞赛和练习平台,它提供了各种难度级别的算法和编程问题,旨在...

Global site tag (gtag.js) - Google Analytics