博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVa11020 · Efficient Solutions
阅读量:7090 次
发布时间:2019-06-28

本文共 2423 字,大约阅读时间需要 8 分钟。

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 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

  • 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 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 groomsafter each performance.

Input

The first line of input gives the number of cases, N (0<N<40)N test cases follow.

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

For each test case, output one line containing "Case #x:" followed by n lines, line i containing the size of the list of efficient grooms after 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.

 

做法:STL太神了。。学了set及multiset的一些用法,这题用multiset维护,很裸,马上就学treap啦。。

转载于:https://www.cnblogs.com/zjdx1998/p/3820535.html

你可能感兴趣的文章
下一代动态网络分析工具FakeNet-NG的Linux平台初体验
查看>>
戴尔安全简化融合网络的管理
查看>>
如何管理云计算和虚拟化环境中的服务器
查看>>
《中国人工智能学会通讯》——12.25 结束语
查看>>
奥巴马拟为网络安全建设增投140亿美元
查看>>
新一代NGIPS 掌控下一代网络安全
查看>>
2012年教育行业IT投资同比增长率超20%
查看>>
一种混合型云计算安全架构
查看>>
大显身手or过度神话?八卦黄金周大数据
查看>>
十年vForum迎来VMware新起点
查看>>
阿里云推出企业级智能协同办公方案 云桌面、云AP、云客服一应俱全
查看>>
为什么你不需要做一名全栈工程师?
查看>>
波音飞机零件供应商遭黑客劫走5千万欧元
查看>>
Django之路 如何开发通用且万能的的权限框架组件
查看>>
三大研究机构预测:6家公司吃掉80%云计算市场
查看>>
爬虫进阶:反爬策略的应对机制
查看>>
轻量函数式 JavaScript:五、降低副作用
查看>>
机器学习----线性回归模型
查看>>
边缘计算产业联盟是一个什么样的联盟?
查看>>
云爆发对许多企业来说仍然过于超前
查看>>