[Poj1548] robots Dilworth theorem (partial sequence set theorem 2)

Source: Internet
Author: User
Tags format definition

Question:

There are some places with garbage, so that the robot can only go to the right or down from the upper left corner, and ask how many times it can clean up all the garbage,

Question:

First, it is a classic question of network flow, or a bipartite graph-minimum path coverage. But now, after all, we are doing some greed. This question uses a greedy correlation theorem, the Dilworth theorem.

This question can be understood as partial order (a walking relationship) between some two points. Er, it can be considered that there is a partial order when XA <= XB & ya <= Yb, if we assume that the reverse direction is reverse order, then the N points of a chain connected by n-1 partial order are defined. Then the answer is "the maximum anti-chain size.
For example, if data 1 in the question is processed, We can get 2 4 4 6 4 7 6 (sorting removes one dimension), and then convert it into the longest descent subsequence.

Obviously, reverse-order pairs cannot reach each other, while reverse-chain is a reverse-Order chain, that is, the longest descending subsequence we want.

Here is a rough idea. The following are two theorems of the partial sequence:

Theorem 1 (X, ≤) is a finite ordinal set, and r is the maximum chain size. Then, X can be divided into R anti-chains but cannot be less.
Its Dual theorem is called the Dilworth theorem:
Theorem 2 (x, ≤) is a finite ordinal set, and m is the maximum size of the anti-chain. Then, X can be divided into M chains but no less chains.
To put it simply, the minimum number of links = the longest length of the anti-chain.


First paste the code question and then the partial order.

Template is http://blog.csdn.net/error/404.html? From = http % 3A % 2f % 2fblog.csdn.net % 2 fvmurder % 2 farticle % 2 fdetails % 2f40818831

Er, the graph is easy to write an O (N ^ 2) algorithm, and the result is always written to O (nlogn). Then (N ^ 2) Forget about various wa... I will never write O (N ^ 2) Lis again !!!

#include <cstdio>#include <cstring>#include <algorithm>#define N 6000#define inf 0x3f3f3f3fusing namespace std;struct KSD{int x,y;bool operator < (const KSD &a)const{if(x==a.x)return y<a.y;return x<a.x;}}s[N];int n,m,f[N];int main(){//freopen("test.in","r",stdin);int i,j,k;int x,y;s[0].y=inf;while(scanf("%d%d",&x,&y),x+1&&y+1){int cnt=0;while(x&&y){s[++cnt].x=x,s[cnt].y=y,scanf("%d%d",&x,&y);}sort(s+1,s+cnt+1);for(i=1;i<=cnt;i++){f[i]=0;for(j=i-1;j>=0;j--){if(s[j].y>s[i].y)f[i]=max(f[i],f[j]+1);}}int ans=0;for(i=1;i<=cnt;i++)ans=max(ans,f[i]);printf("%d\n",ans);}return 0;}





Partial Order relation exists Partial Order A< B, A< C, Then BAnd CCannot compare the data size. The corresponding full order must be shown A< B< C. That is, the full order requires that each element be able to compare the size, and the partial order is not required. Directory

1 Overview

2. Example:

1 Overview
Format definition: Set R to a set AIf R satisfies: I self-inverse: For any Xε A, Yes XR X; Ⅱ anti-symmetry: For any X, Yε A, If XR Y, And YR X, Then X= Y; Ⅲ transmission: For any X, Y, Zε A, If XR Y, And YR Z, Then XR Z. R is called AThe partial order relationship above is usually recorded ?. Note here? It does not need to be "less than or equal to" in the general sense ". If you have X? Y, We also say XRanked YFront ( XPrecedes Y). 2. Example:
Examples of Self-inverse and pass-ability mentioned above: Set A= { A, B, CThe relation R on...} indicates that R has ( A, A),( B, B),( C, C)... R is a transfer, that is, if there is ( A, B) And ( B, C), Then ( A, C). Partial Order(Partial order) concept: Set AIs a non-empty set, P is AIf P satisfies the following conditions: Aε A, (A, a) ε P; (inverse reflexlve) ⅱ if ( A, B) ε P, and ( B, A) ε P, then A= B; (Anti-symmetry, anti-symmentric) if ( A, B) ε P ,( B, C) ε P, then ( A, C(Transmitter, transitive) is called P AA partial order relationship on. If P is AWe use ABTo indicate ( A, B. An integer-division relationship is a partial order relation defined on a natural number. |, 3 | 6 indicates 3-Division 6. Greater than or equal to a partial order relation defined in a natural number set. The Chinese name of the prefix is written as an inverse (self-inverse) pair. Then, X is x. (Inverse symmetry) If X is Y and Y is X, X = y; if R is set to a non-empty set, if R is self-inverse, antisymmetric, and transferred, then R is called a partial order relation on a, or partial order for short, it is usually recorded as a delimiter. The partial order relation R on A and A is called the partial sequence set, which is recorded as <A, R> or <A, strong>. (Self-inverse) for any one, then x; (Anti-Symmetry) If X ≦ y and Y ≦ X, then x = y; (pass-through) If X ≦ y, and y Branch C, then x Branch C.


[Poj1548] robots Dilworth theorem (partial sequence set theorem 2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.