首页 > ACM题库 > HDU-杭电 > hdu 2230 This time, two, not one待解决[解题报告]C++
2014
01-04

hdu 2230 This time, two, not one待解决[解题报告]C++

This time, two, not one

问题描述 :

I konw you guys have solve so many problems about increasing sequence, this time, a little change has been made.
Assume that there is a sequence S = {s1, s2, s3, …, sn}, si = (xi, yi).You should find two increasing subsequence L1 and L2, and they have no common elements, means L1∩L2 = φ, and the sum of their lenth is as max as possible.
Here we assume si > sj is that (xi > xj && yi > yj) or (xi >= xj && yi > yj) or (xi > xj && yi >= yj). I will ensure that all elements’ coordinates are distinct, i.e., si != sj (i!=j).

输入:

The input consists of multiple test cases. Each case begins with a line containing a positive integer n that is the length of the sequence S, the next n lines each contains a pair integers (xi, yi), i = 1,…n.1 <= n <= 5000,1<=xi,yi<=2^31.

输出:

The input consists of multiple test cases. Each case begins with a line containing a positive integer n that is the length of the sequence S, the next n lines each contains a pair integers (xi, yi), i = 1,…n.1 <= n <= 5000,1<=xi,yi<=2^31.

样例输入:

3
1 3
3 1
2 2
4
1 2
2 1
4 3
3 4

样例输出:

2
4

Hint: In the second case, you can make L1 = {(1,2), (3,4)} and L2 = {(2,1), (4,3)}, or L1 = {(1,2), (4,3)} and L2 = {(2,1), (3,4)}.


  1. 很高兴你会喜欢这个网站。目前还没有一个开发团队,网站是我一个人在维护,都是用的开源系统,也没有太多需要开发的部分,主要是内容整理。非常感谢你的关注。