标签:style io color os ar for sp 数据 div
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<stdlib.h> struct Node { int x; int y; }s[1001]; int com(const void *a,const void *b) { struct Node *c=(Node *)a; struct Node *d=(Node *)b; return c->x-d->x; } int main(void) { int N; scanf("%d",&N); getchar(); while(N--) { int dp[1001]; int i,j; int n; int a,b; scanf("%d",&n); getchar(); for(i=0;i<n;i++) { scanf("%d%d",&a,&b); if(a>b) { s[i].x=a; s[i].y=b; } else { s[i].x=b; s[i].y=a; } } qsort(s,n,sizeof(s[0]),com); for(i=0;i<n;i++) { dp[i]=1; for(j=0;j<i;j++) { if(s[j].y<s[i].y&&s[j].x<s[i].x&&dp[i]<dp[j]+1) dp[i]=dp[j]+1; } } int max=0; for(i=0;i<n;i++) if(max<dp[i]) max=dp[i]; printf("%d\n",max); } return 0; }
标签:style io color os ar for sp 数据 div
原文地址:http://blog.csdn.net/qq_16997551/article/details/40621863