1821: [Jsoi2010]group Tribe Division Group

Source: Internet
Author: User

1821: [Jsoi2010]group Tribe Division Group time limit:10 Sec Memory limit:64 MB
submit:1308 solved:627
[Submit] [Status] Description Cong study found that the desert Island Savage always live a gregarious life, but not the whole island of all savages belong to the same tribe, the wild people always cliques form belong to their own tribe, different tribes are often fighting. It's just that it's all a mystery-Cong doesn't know how the tribe is distributed. But the good news is that Cong got a map of the desert island. The map marks the place where N Savages Live (which can be seen as coordinates on the plane). We know that savages of the same tribe always live nearby. We defined the distance of the two tribes as the distance between the two closest settlements in the tribe. Cong also got a meaningful message-the savages were divided into K-tribes in total! That's a good news. Cong hopes to dig out the details of all the tribes from this information. He was experimenting with an algorithm that could find the distance between two tribes for any one tribe division, and Cong hoped to find a way to divide the tribe so that the nearest two tribes could be kept as far away as possible. For example, the diagram on the left shows a good division, while the right is not. Please program to help Cong solve this problem. The first line of input contains two integers N and K (1<=n<=1000,1<k<=n), respectively, representing the number of inhabitants of the savage and the number of tribes. The next n rows, each line containing two positive integers x, y, describe the coordinates of a dwelling point (0<= "x," y<= "10000). "<=" "div=" ">output output line, for optimal division, the distance of the nearest two tribes, accurate to two digits after the decimal point. Sample Input4 2
0 0
0 1
1 1
1 0


Sample Output1.00

HINT Source

JSOI2010 Second round Contest1

The problem: Meng Meng's smallest spanning tree does not explain (ha ha Jsoi unexpectedly also appeared such topic)

1/**************************************************************2Problem:18213 User:hansbug4 language:pascal5 result:accepted6Time:272Ms7Memory:25656KB8****************************************************************/9  Ten var One I,j,k,l,m,n,tt:longint; AA,d:Array[0..1000050,1..2] ofLongint; -   -B:Array[0..1000050] ofextended; theC:Array[0..10050] ofLongint; - functionGetfat (x:longint): Longint;inline; -          begin -               ifC[x]<>x Thenc[x]:=Getfat (c[x]); +getfat:=C[x]; -          End; + proceduremerge (X,y:longint), inline; A           varA1,a2:longint; at           begin -A1:=getfat (x); a2:=Getfat (y); -                ifA1=a2 Thenexit; -DEC (TT); c[a1]:=A2; -           End; - functiontog (x,y:longint): Boolean;inline; in          begin -Exit (Getfat (x) =Getfat (y)); to          End; + procedureSwapvarx,y:longint); inline; -           varZ:longint; the           begin *z:=x;x:=y;y:=Z; $           End;Panax Notoginseng proceduresort (l,r:longint); -           vari,j:longint;x,y:extended; the           begin +i:=l;j:=r;x:=b[(L+r)Div 2]; A                Repeat the                       whileB[i]<x DoInc (i); +                       whileB[j]>x DoDec (j); -                      ifI<=j Then $                         begin $y:=B[i]; -b[i]:=B[j]; -b[j]:=y; theSwap (A[i,1],a[j,1]); -Swap (A[i,2],a[j,2]);Wuyi Inc (I);d EC (j); the                         End; -                untilI>J; Wu                ifI<r Thensort (i,r); -                ifL<j Thensort (l,j); About           End; $   - begin - readln (n,m); -       fori:=1  toN Do AREADLN (D[i,1],d[i,2]); +k:=0; the       fori:=1  toN-1  Do -           forj:=i+1  toN Do $              begin the Inc (k); theA[k,1]:=i; theA[k,2]:=J; theB[k]:=sqrt (Sqr (D[i,1]-d[j,1]) +sqr (D[i,2]-d[j,2])); -              End; intt:=N; the       fori:=1  toN Doc[i]:=i; theSort1, k); Abouti:=0; the       whileTt>m Do the            begin the Inc (i); +                  whileTog (A[i,1],a[i,2]) DoInc (i); -Merge (A[i,1],a[i,2]); the            End;Bayi Inc (i); the       whileTog (A[i,1],a[i,2]) DoInc (i); theWriteln (B[i]:0:2); - End.

1821: [Jsoi2010]group Tribe Division Group

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.