Two times Unicom gate: Bzoj 1015: [JSOI2008] Star Wars Starwar
/*bzoj 1015: [JSOI2008] Star Wars Starwar offline Delete point first to create a plot after the deletion point and then a point to add the deleted points*/#include<cstdio>#include<iostream>#defineMax 400004#defineRG Registerstructe {e *n;intV } *list[max], Poor[max], *ta =Poor;intF[max], C, P[max], S[max];BOOL is[Max];inlinevoidRead (int&N) {RGCharc =GetChar (); for(n =0;!isdigit (c); c =GetChar ()); for(; IsDigit (c); n = n *Ten+ C-'0', C = GetChar ()); ++N;} InlineintFind (intx) {returnF[X] = = x? X:F[X] =Find (f[x]);}intMain (intargcChar*argv[]) { intN, M, n, x, Y, V, K; Read (N), read (M); RgintI, J; --N,--M; Ee; for(i =0; i < M; ++i) {read (x), read (y); + + ta, ta->n = list[x], list[x] = ta, ta->v =y; + + ta, ta->n = List[y], list[y] = ta, ta->v =x; } read (K); --K; C = n-k; for(i =1; I <= N; F[i] = i, + +i); for(i =1; I <= K; + + i) read (P[i]), is[P[i]] =true; for(i =1; I <= N; ++i) {if( is[i])Continue; for(e = list[i]; e; e = e->N)if(! is[(V = e->v)]) {x= Find (i), y =Find (V); if(x! = y) f[x] = y,--C; } } for(i = K, S[k +1] = C; I >=1; --i) {n= P[i], is[N] =false; ++C; for(e = list[n]; e; e = e->N)if(! is[(V = e->v)]) {x= Find (n), y =Find (V); if(x! = y) f[x] = y,--C; } S[i]=C; } for(i =1; I <= K +1; + + i) printf ("%d\n", S[i]);return 0;}
Bzoj 1015: [JSOI2008] Star Wars Starwar