博客
关于我
强烈建议你试试无所不能的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/

你可能感兴趣的文章
Leetcode C++《热题 Hot 100-18》538.把二叉搜索树转换为累加树
查看>>
Leetcode C++《热题 Hot 100-21》581.最短无序连续子数组
查看>>
Leetcode C++《热题 Hot 100-22》2.两数相加
查看>>
Leetcode C++《热题 Hot 100-23》3.无重复字符的最长子串
查看>>
Leetcode C++《热题 Hot 100-24》5.最长回文子串
查看>>
Leetcode C++《热题 Hot 100-28》19.删除链表的倒数第N个节点
查看>>
Leetcode C++《热题 Hot 100-29》22.括号生成
查看>>
阿里云《云原生》公开课笔记 第二章 容器基本概念
查看>>
阿里云《云原生》公开课笔记 第三章 kubernetes核心概念
查看>>
阿里云《云原生》公开课笔记 第四章 理解Pod和容器设计模式
查看>>
阿里云《云原生》公开课笔记 第五章 应用编排与管理
查看>>
阿里云《云原生》公开课笔记 第六章 应用编排与管理:Deployment
查看>>
阿里云《云原生》公开课笔记 第七章 应用编排与管理:Job和DaemonSet
查看>>
阿里云《云原生》公开课笔记 第八章 应用配置管理
查看>>
阿里云《云原生》公开课笔记 第九章 应用存储和持久化数据卷:核心知识
查看>>
linux系统 阿里云源
查看>>
国内外helm源记录
查看>>
牛客网题目1:最大数
查看>>
散落人间知识点记录one
查看>>
Leetcode C++ 随手刷 547.朋友圈
查看>>