矩形嵌套 南工16
来源:互联网 发布:qq飞车飞碟数据 编辑:程序博客网 时间:2024/06/05 15:32
题目链接:here~~
先排序再求才AC了
#include <iostream>#include <cstdio>#include <string.h>#include <algorithm>using namespace std;struct cd{ int x, y; bool operator < (cd r)const { if (x==r.x) return y<r.y; else return x<r.x; }}a[1001];int res[1001];int main(){ int n, m, i, j, max, t;// freopen("in.txt", "r", stdin); scanf("%d", &n); while (n--) { cin>>m; memset(a, 0, sizeof(a)); memset(res, 0, sizeof(res)); for (i = 0; i<m; i++) { cin>>a[i].x>>a[i].y; if (a[i].x>a[i].y) { t = a[i].x; a[i].x=a[i].y; a[i].y=t; } } sort(a, a+m); for (i=0; i<m; i++) { if (i==0) { res[i]=1; continue; } max = 0; for (j = 0; j<i; j++) { if (a[i].x>a[j].x&&a[i].y>a[j].y&&max<res[j]) max = res[j]; } res[i]=max+1; } max = 0; for (i=0; i<m; i++) { if (max<res[i]) max=res[i]; // cout<<res[i]<<" "<<a[i].x<<" "<<a[i].y<<endl; } cout<<max<<endl; } return 0;}
- 矩形嵌套 南工16
- NYOJ 16 矩形嵌套
- nyoj 16 矩形嵌套
- 题目16: 矩形嵌套
- NYOJ 16 矩形嵌套
- nyoj 16 矩形嵌套
- nyoj-16-矩形嵌套
- NYOJ 16 矩形嵌套
- NYOJ 16 矩形嵌套
- 嵌套矩形(nyoj 16)
- 矩形嵌套(nyoj 16)
- NYOJ 16 矩形嵌套
- NYOJ 16 矩形嵌套
- nyoj 16 矩形嵌套
- NYOJ 16 矩形嵌套
- NYOJ-16-矩形嵌套
- NYOJ 16 矩形嵌套
- NYOJ 16 - 矩形嵌套
- 字符串拷贝函数
- sql常用函数之日期、text函数
- String Date Timestamp之间的转化
- I2C总线之简介
- Nexys3学习手记:ClockingWizard探秘
- 矩形嵌套 南工16
- 字符串循环右移N个
- Python 和 bash shell脚本(python和shell, python中文件操作, python中目录操作)
- Qwt源码解读之QwtSpline类
- tcpdump的用法
- !!!Chapter 4 Trees ST/BT
- <Unity 3D工作笔记>游戏角色 - 经验条的制作
- 营销不应是一个部门,我们所有人都在营销
- 设置元素的属性