1 10 1 2 2 4 5 8 6 10 7 9 3 1 5 8 12 10 9 7 2 2
5
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct space
{
int a;
int b;
}c[1005];
BOOL CMP (Space _x, space _y) / / must be sorted
{
if(_x.a==_y.a)
return _x.b<_y.b;
else
return _x.a<_y.a;
}
int main()
{
int N,n,p,q,i,j,dp[1005];
scanf("%d",&N);
while(N--)
{
memset(dp,0,sizeof(dp));
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d",&p,&q);
c[i].a=p>q?p:q;
c[i].b=p<q?p:q;
}
sort(c,c+n,cmp);
int k=1;
for(i=0;i<n;i++)
{
dp[i]=1;
for(j=0;j<i;j++)
{
if(c[j].b<c[i].b&&c[j].a<c[i].a&&dp[j]+1>dp[i])
dp[i]=dp[j]+1;
}
if(k<dp[i])
k=dp[i];
}
printf("%d\n",k);
}
return 0;
}
Description has n rectangles, each rectangle Use A, B to describe, indicating long and wide. Rectangular X (A, B) can be nested in rectangular Y (C, D) and is only used in rectangular Y (C, D) and is ...
topic: answer: A typical longest increasing subsequence problem But it becomes two-dimensional, so we only need to use the structure to quickly arrange it to make it into the order we want, and only l...
Rectangular nesting time limit:3000 ms| Memory limit: 65535 KB Difficulty:4 description Haven rectangles, each rectangle can be described by a, b, which means length and width. The rectangle X(a, b) c...
Rectangular Nesting [Java] description Sample input Sample Output Code Time limit: 3000 ms | Memory Limit: 65535 KB Difficulty: 4 description With n rectangles, each rectangle can be used a, b describ...
#include <stdio.h> int main() { int T; scanf("%d",&T); while(T--) { int a,b;  ...
Nested query with the predicate in the Acceptable nested. is the result of this query is Cno 'C02' of the Sno Sname and Dno. where () parentheses tag as subqueries. It is known as the father query or ...
4.2 ifNesting elifThe application scenario is: judging multiple conditions at the same time, all conditions are level l In development, useifConditional judgment, if you want to add conditional j...
16. Nested route As shown above, componentsmainMultiple components can be madeProfilećPostTogether constitute oneVueinterface.Instead of a component represents a page, only the jump to generate a page...
Time limit: 3000 ms | Memory limit: 65535 KB Difficulty: 2 Describe Seeking a three-row three column transpressive matrix. input The first line of an integer n <20, indicating that there is N group...
Seeking a matrix problem time limit:3000MS | Memory Limit:65535 KB Difficulty:2 description Seeking a three-row three column transposition matrix. input The first line is an integer n <20, ind...