Rectangular nesting time limit: 3000 MS | memory limit: 65535 KB difficulty: 4
-
Description
-
There are n rectangles. Each rectangle can be described by a and B to indicate length and width. Rectangle X (a, B) can be nested in Rectangle Y (c, d) When and only when
-
Input
-
The first line is a positive number N (0 The first row of each group of test data is a positive number n, indicating the number of rectangles in the group of test data (n <= 1000)
Next n rows, each row has two numbers a and B (0 output
-
Each group of test data outputs one number, indicating the maximum number of rectangles that meet the conditions. Each group of output occupies one row.
-
Sample Input
-
1101 22 45 86 107 93 15 812 109 72 2
-
Sample output
-
5
-
Source
-
Typical questions
-
Uploaded
-
Zhang yuncong
-
-
This question has been around for a long time. It's quite easy to read it in the white book, but I have made a lot of mistakes and exposed all my shortcomings. It's quite good!
-
At the beginning, we used vector to create a map directly. We didn't see it at the beginning, and then we felt it. We changed it to an array adjacent table, which was 2688 ms, so we ran through water. Creating a map with a matrix is only 12 ms at all ...... The graph in the question is exactly a dense graph, so no matter whether it is a vector or an array, there are many times of joining the table. This is also the reason, sister! I have not encountered this problem before doing graph theory, but now I have finally met it.
-
#include
#include
#include #include
#include
#include
#include
#include
#include
#include
#include
#include
#define PI acos(-1.0)#define mem(a,b) memset(a,b,sizeof(a))#define sca(a) scanf(%d,&a)#define sc(a,b) scanf(%d%d,&a,&b)#define pri(a) printf(%d,a)#define lson i<<1,l,mid#define rson i<<1|1,mid+1,r#define MM 204#define MN 1008#define INF 2000000000#define eps 1e-8using namespace std;typedef long long ll;typedef unsigned long long ULL;int n,dp[MN],head[MN*10],cnt;struct node{ int x,y;}e[MN];struct no{ int v,next;}ee[MN*10];void add(int u,int v){ ee[cnt].v=v,ee[cnt].next=head[u],head[u]=cnt++;}bool cmp(node a,node b){ if(a.x==b.x) return a.y
y) swap(x,y); e[i].x=x,e[i].y=y; } sort(e+1,e+n+1,cmp); for(i=1;i<=n;i++) for(j=i+1;j<=n;j++) if(e[i].x