博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第七届河南省赛H.Rectangles(lis)
阅读量:1546 次
发布时间:2019-04-21

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

10396: H.Rectangles

Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 229  Solved: 33 [ ][ ][ ]

Description

Given N (4 <= N <= 100)  rectangles and the lengths of their sides ( integers in the range 1..1,000), write a program that finds the maximum K for which there is a sequence of K of the given rectangles that can "nest", (i.e., some sequence P1, P2, ..., Pk, such that P1 can completely fit into P2, P2 can completely fit into P3, etc.).

 

A rectangle fits inside another rectangle if one of its sides is strictly smaller than the other rectangle's and the remaining side is no larger.  If two rectangles are identical they are considered not to fit into each other.  For example, a 2*1 rectangle fits in a 2*2 rectangle, but not in another 2*1 rectangle.

 

The list can be created from rectangles in any order and in either orientation.

 

Input

The first line of input gives a single integer, 1 ≤ T ≤10,  the number of test cases. Then follow, for each test case

* Line 1:       a integer N ,  Given the number ofrectangles  N<=100

* Lines 2..N+1:  Each line contains two space-separated integers  X  Y,  the sides of the respective rectangle.   1<= X , Y<=5000

 

Output

Output for each test case , a single line with a integer  K ,  the length of the longest sequence of fitting rectangles.

Sample Input

148 1416 2829 1214 8

Sample Output

2

HINT

 

Source

题解:矩形嵌套数目,只需要把x从小到大排列,找lis就好了;注意x要比y小,lis要upper;

代码:

#include
#include
#include
#include
#include
#include
using namespace std;#define mem(x,y) memset(x,y,sizeof(x))#define SI(x) scanf("%d",&x)#define SL(x) scanf("%lld",&x)#define PI(x) printf("%d",x)#define PL(x) printf("%lld",x)#define P_ printf(" ")const int INF=0x3f3f3f3f;const double PI=acos(-1.0);typedef long long LL;struct Node{ int x,y; friend bool operator < (Node a,Node b){ if(a.x!=b.x)return a.x
vec; for(int i=0;i

  

转载地址:http://pmdcy.baihongyu.com/

你可能感兴趣的文章
reactos操作系统实现(101)
查看>>
Android培训班(75)Dalvik虚拟机的GetStaticMethodID函数
查看>>
新手也可以学会TensorFlow
查看>>
游戏制作之路(32)创建自定义的界面样式管理
查看>>
从小说里学会长大
查看>>
iBATIS&Spring合奏(一)--DAO
查看>>
iBATIS&Spring合奏(二)--Flex前端融合
查看>>
iBATIS&Spring合奏(三)--事务&动态SQL
查看>>
C++核心准则C.48:如果构造函数需要用常数初始化成员,使用类内初始化器更合适
查看>>
C++核心准则C.49:构造函数中应该做的是初始化而不是赋值
查看>>
C++核心准则C.50:如果在构造过程中需要“虚行为”,使用工厂函数
查看>>
C++核心准则C.51:使用委托构造函数实现所有构造函数的共通动作
查看>>
C++核心准则C.52:合理使用继承的构造函数
查看>>
基于Chrome浏览器的前端调试
查看>>
Python:Flask部署Nginx、gunicorn、gevent、flask、supervisor
查看>>
【李宏毅2020 ML/DL】补充:Ensemble: Bagging, Boosting, Adaboost, Gradient Boosting, Stacking
查看>>
【Computer Organization笔记24】光盘,FLASH MEMORY,本单元总结
查看>>
【必收藏】台大李宏毅老师课程 | 资源汇总、笔记总结与索引
查看>>
【Computer Organization笔记25】I/O:程序直接控制,程序中断方式,直接存储访问(DMA),通道控制方式
查看>>
【Computer Organization笔记26】总线 bus :多个部件之间进行数据传送的共享通道,总线设计 - 总线仲裁、数据传输模式、提高总线性能
查看>>