Bzoj 1015: [JSOI2008] Star Wars Starwar

Source: Internet
Author: User

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

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.