And find out about the bzoj1015 of the mess.

Source: Internet
Author: User

Construction of the wrong 4 times changed 2 clock ... This is a water problem ...

1  Programhehe;2 type3Edge=Record4 Q,z,next:longint;5  End;6 var7 N,m,q,i,j,k,cnt:longint;8P,PD:Array[0..500000] ofBoolean;9E:Array[0..500000] ofEdge;TenAns,c,first,f,d:Array[0..500000] ofLongint; One  A   functionFind (A:longint): Longint; -   begin -    ifF[a]=a Thenexit (a); thef[a]:=find (F[a]); - exit (F[a]); -   End; -  + begin -Fillchar (first,sizeof (first),255); +Fillchar (E,sizeof (E),255); A Fillchar (P,sizeof (P), true); at read (n,m); -   fori:=0  toN-1  Do -f[i]:=i; -   fori:=1  toM Do -  begin - read (j,k); in   iffirst[j]=-1  Then -first[j]:=i; toe[i].q:=J; +e[i].z:=K; -e[c[j]].next:=i; thec[j]:=i; *   iffirst[k]=-1  Then $first[k]:=i+m;Panax Notoginsenge[i+m].q:=J; -e[i+m].z:=K; thee[c[k]].next:=i+m; +c[k]:=i+m; A  End; the read (q); +   fori:=1  toQ Do -  begin $Read (d[q-i+1]); $p[d[q-i+1]]:=false; -  End; -   fori:=0  toN-1  Do the  ifP[i] ThenInc (CNT); -   fori:=0  toN-1  DoWuyi  ifP[i] Then the  begin -k:=First[i]; Wu    whilek<>-1  Do -   begin About    if(P[E[K].Q]) and(P[e[k].z]) Then $    ifFind (E[K].Q) <>find (E[K].Z) Then -    begin -F[find (E[K].Q)]:=find (e[k].z); - Dec (CNT); A    End; +k:=E[k].next; the   End; -  End; $ans[0]:=CNT; the   fori:=1  toQ Do the  begin the Inc (CNT); thep[d[i]]:=true; -k:=First[d[i]]; in    whilek<>-1  Do the   begin the    if(P[E[K].Q]) and(P[e[k].z]) Then About    ifFind (E[K].Q) <>find (E[K].Z) Then the    begin theF[find (E[K].Q)]:=find (e[k].z); the Dec (CNT); +    End; -k:=E[k].next; the   End;Bayians[q-i+1]:=CNT; the  End; the   fori:=1  toQ Do - Writeln (Ans[i]); -Writeln (ans[0]); the End.
View Code 1015: [JSOI2008] Star Wars Starwar time limit:3 Sec Memory limit:162 MB
submit:3484 solved:1554
[Submit] [Status] [Discuss] Description

Long ago, in a distant galaxy, a dark empire was leaning against its super-weapons rulers throughout the galaxy. One day, with an occasional chance, a rebel army destroyed the empire's super weapons and attacked almost all the planets in the galaxy. These planets are connected to each other directly or indirectly through special etheric tunnels. But it was not long, and soon the Empire re-created his super weapon. With the power of this super weapon, the Empire began to plan to destroy the rebel-occupied planet. As the planet continues to be destroyed, communication channels between the two planets are beginning to be unreliable. Now, the rebel leader gives you a mission: to give the connection of the etheric tunnels between the original two planets and the order of the planets in the Empire's attack, to find out the number of connected fast planets that the rebels occupy after each strike as quickly as possible. (If two planets can be connected directly or indirectly through existing etheric channels, the two planets are in the same connected block).

Input

The first line of the input file contains two integers, n (1 <= n <= 2M) and M (1 <= m <= 200,000), respectively, representing the number of planets and the number of etheric tunnels. Planets are numbered with 0~n-1 integers. The next M-line, each line consists of two integers X, Y, where (0<=x<>y

Output

The first line of the output file is the number of connected blocks at the beginning of the planet. The next n rows, one integer per line, indicate the number of connected blocks of the existing planet after the strike.

Sample Input8 13
0 1
1 6
6 5
5 0
0 6
1 2
2 3
3 4
4 5
7 1
7 2
7 6
3 6
5
1
6
3
5
7Sample Output1
1
1
2
3
3HINT Source [Submit] [Status] [Discuss]

And find out about the bzoj1015 of the mess.

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.