Topic: Given a chord graph, the minimum staining is obtained.
String graph related issues, see Chen Danqi 09 Speech "String and interval map"
PPT has a problem is not clear is the MCS algorithm O (m+n) How to the http://tieba.baidu.com/p/2891159900 have JCVB God Ben Detailed answers
As for how the stain is labeled, the timestamp marks the violent swipe
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define M 10100using namespace Std;struct abcd{int to,next;} Table[4004004];int head[m],tot;int n,m,ans,best,f[m],list[m],seq[m],color[m],mark[m];bool v[M];void Add (int h[],int X,int y) {table[++tot].to=y;table[tot].next=h[x];h[x]=tot;} void MCS () {int i,j;for (i=1;i<=n;i++) Add (list,0,i); for (j=n;j;j--) {while (1) {for (I=list[best];i;i=table[i].next) {if (!v[table[i].to]) Break;elselist[best]=table[i].next;} if (i) {int x=table[i].to;v[x]=1;seq[j]=x;for (i=head[x];i;i=table[i].next) if (!v[table[i].to]) {f[table[i].to]++; ADD (list,f[table[i].to],table[i].to); Best=max (best,f[table[i].to]);} break;} elsebest--;}}} int main () {int i,j,x,y;cin>>n>>m;for (i=1;i<=m;i++) {scanf ("%d%d", &x,&y); ADD (Head,x,y); ADD (head,y,x);} MCS (); for (j=n;j;j--) {x=seq[j];for (I=head[x];i;i=table[i].next) mark[color[table[i].to]]=j;for (i=1;i<=n& &mark[i]==j;i++); Color[x]=i;ans=max (ans,i);} Cout<<ans<<eNDL;}
Bzoj 1006 HNOI2008 The magical national chord graph minimum staining MCS algorithm