Bzoj 1015: [JSOI2008] Star Wars Starwar

Source: Internet
Author: User

1#include <cstdio>2#include <iostream>3 #defineM 20000004 intcnt,fa[m],n,m,ans[m],k,f[m],a[m],head[m],next[2*m],u[2*M];5 intZhaointA1)6 {7     if(a1==FA[A1])8       returnA1;9fa[a1]=Zhao (fa[a1]);Ten     returnFA[A1]; One } A voidJiaintA1,intA2) - { -cnt++; thenext[cnt]=HEAD[A1]; -u[cnt]=A2; -head[a1]=CNT; -      return;  + } - intMain () + { Ascanf"%d%d",&n,&m); at      for(intI=1; i<=m;i++) -       { -         inta1,a2; -scanf"%d%d",&a1,&A2); -a1++; -a2++; in Jia (A1,A2); - Jia (a2,a1); to       } +scanf"%d",&k); -      for(intI=1; i<=k;i++) the       { *         intA1; $scanf"%d",&A1);Panax Notoginsenga[i]=++A1; -f[a1]=1; the       } +      for(intI=1; i<=n;i++) Afa[i]=i; theans[k]=n-K; +      for(intI=1; i<=n;i++) -       if(!F[i]) $          for(intj=head[i];j;j=Next[j]) $           if(!F[u[j]]) -             { -               intB1=zhao (i), b2=Zhao (u[j]); the               if(b1!=B2) -                {Wuyifa[b1]=B2; theans[k]--; -                }  Wu             } -      for(inti=k;i;i--) About       { $f[a[i]]=0; -ans[i-1]=ans[i]+1; -          for(intj=head[a[i]];j;j=Next[j]) -           if(!F[u[j]]) A             { +               intB1=zhao (A[i]), b2=Zhao (u[j]); the               if(b1!=B2) -               { $fa[b1]=B2; theans[i-1]--; the               } the             } the       } -      for(intI=0; i<=k;i++) inprintf"%d\n", Ans[i]); the     return 0; the}

The problem is offline to deal with the first delete all the deleted, and then add, use and check set maintenance can, of course, the deletion of the topic is the point, do not forget Ah!!

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.