No transmission door spicy.
A magical DP question.
First of all see this problem first should think that the positive solution is not on the diagram, it is sure to convert the original image into a sequence.
According to the nature of the reverse order. Each point and label is greater than the point of his point, the weight must be less than that point, and he does not have the edge and the label is greater than his point, the weight of the value must be greater than him.
According to this, we can increment the enumeration label, each time to determine the point and a number of labels greater than his point to the right, that is, determine how many points in the unchecked weight is smaller than him.
You can then determine the label of the current point.
This successfully transforms the original image into a sequence.
Next consider doing DP on the sequence.
Obviously, if some of the selected points are satisfied. It is necessary to satisfy a ascending sub-sequence, and only the point set of ascending subsequence is the independent set of the title.
The cover set is not so well handled. Assuming that we have selected a bunch of points, then for unselected points, there must be an inverse pair with one of the points. Use the mathematical formula to show that this is the case:
$\forall a_i \notin v_1$, must $\exists a_j \in v_2$ make $a_i>a_j$ and $i<j$ or $a_i<a_j$ and $i>j$.
So next consider a fragment on the sequence $ (l,r) $, where $l,r$ are already the points that have been king-James. Then for all points in $ (l,r) $ $a_i$, must not meet $a_l \leq a_i \leq a_r$.
But there can be no one point satisfying the above conditions but is there an inverse relationship with the previous point?
Consider a point satisfying the above conditions. Then the other king is either greater than $a_l$, or less than $a_r$, so that it does not satisfy the independent set of the relationship.
So you can do the DP according to this.
That is, $f[i]$ represents the number of scenarios ending with $i$, plus some small optimizations to meet the complexity of $o (n^2) $.
Senritsu//by cydiater//2017.1.17#include <iostream> #include <queue> #include <map> #include < ctime> #include <cstring> #include <string> #include <iomanip> #include <ctime> #include < algorithm> #include <cstdlib> #include <cstdio> #include <bitset> #include <set> #include <vector>using namespace std; #define LL Long long#define up (i,j,n) for (int. i=j;i<=n;i++) #define DOWN (i,j,n) for ( int i=j;i>=n;i--) #define CMAX (A, B) A=max (A, b) #define Cmin (A, B) A=min (A, b) #define Auto (I,node) for (int i=link[node]; I;i=e[i].next) #define FILE "Senritsu" const int maxn=1e4+5;const int OO=0X3F3F3F3F;CONST int Mod=1000000007;inline int Read () {char ch=getchar (); int x=0,f=1;while (ch> ' 9 ' | | ch< ' 0 ') {if (ch== '-') F=-1;ch=getchar ();} while (ch>= ' 0 ' &&ch<= ' 9 ') {x=x*10+ch-' 0 '; Ch=getchar ();} return x*f;} int N,m,link[maxn],len=0,arr[maxn],f[maxn];bool used[maxn];struct edge{int y,next;} E[maxn<<10];namespace solution{inline void Insert (int x,int y) {e[++len].next=link[x]; Link[x]=len;e[len].y=y;} inline void Insert (int x,int y) {insert (x, y); insert (y,x);} void Prepare () {n=read (); M=read (); up (i,1,m) {int x=read (), Y=read (); Insert (x, y);} Up (i,1,n) {int cnt=0,k=0; Auto (J,i) if (e[j].y>i) cnt++;up (j,1,n) if (!used[j]) {k++;if (k==cnt+1) {used[j]=1;arr[i]=j;break;}}} Arr[0]=-oo;arr[n+1]=oo-1;} void Solve () {int min;f[0]=1;up (i,0,n+1) {min=oo;up (j,i+1,n+1) {if (Arr[j]>arr[i]&&min>arr[j]) (f[j]+=f [i]) %=mod;if (Arr[j]>arr[i]) cmin (Min,arr[j]);}} Cout<<f[n+1]<<endl;}} int main () {freopen (file ".", "R", stdin), freopen (file ". Out", "w", stdout); using namespace solution; Prepare (); Solve (); return 0;}
[HAOI2017 simulation] prisoner's melody