# Uva10803_thunder Mountain (Short Circuit) (graph theory)

Source: Internet
Author: User

Solution report

Bare Floyd.

`#include <iostream>#include <cstring>#include <cstdio>#include <cmath>#define inf 0x3f3f3f3fusing namespace std;int n;double mmap[210][210];struct node {    double x,y;} p[210];double disc(node p1,node p2) {    return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));}void floyd() {    for(int k=0; k<n; k++)        for(int i=0; i<n; i++)            for(int j=0; j<n; j++)                mmap[i][j]=min(mmap[i][j],mmap[i][k]+mmap[k][j]);}int main() {    int i,j,t,k=1;    scanf("%d",&t);    while(t--) {        scanf("%d",&n);        for(i=0; i<n; i++) {            scanf("%lf%lf",&p[i].x,&p[i].y);        }        for(i=0; i<n; i++) {            for(j=0; j<n; j++) {                double d=disc(p[i],p[j]);                if(d<=10)                    mmap[i][j]=d;                else mmap[i][j]=inf;            }            mmap[i][i]=0;        }        floyd();        double  ans=0;        for(i=0; i<n; i++) {            for(j=0; j<n; j++) {                if(mmap[i][j]>ans)                    ans=mmap[i][j];            }        }        printf("Case #%d:\n",k++);        if(ans==inf)            printf("Send Kurdy\n");        else {            printf("%.4lf\n",ans);        }        printf("\n");    }}`

Problem?
Thunder Mountain
Time Limit: 3 seconds

 "I mean, some people got guns, and somePeople got flashlights, and some people gotBatteries. These guys had all three ."

J. Michael straczynski, "Jeremiah ."

Markus is building an army to fight the edevil Valhalla sector, so he needs to move some supplies between several of the nearby towns. the woods are full of robbers and other unfriendly folk, so it's dangerous to travel far. as Thunder Mountain's head of security, Lee thinks that it is unsafe to carry supplies for more than 10 km without visiting a town. markus wants to know how far one wowould need to travel to get from one town to another in the worst case.

Input
The first line of input gives the number of cases,N.NTest Cases Follow. Each one starts with a line containingN(The number of towns, 1 <N<101). The nextNLines will give the XY-locations of each town in km (integers in the range [0, 1023]). assume that the earth is flat and the whole 1024x1024 grid is covered by a forest with roads connecting each pair of towns that are no further than 10 km away from each other.

Output
For each test case, output the line "case #X: ", WhereXIs the number of the test case. on the next line, print the maximum distance one has to travel from town a to town B (for some A and B ). round the answer to 4 decimal places. every answer will obey the formula

`fabs(ans*1e4 - floor(ans*1e4) - 0.5) > 1e-2`

If it is impossible to get from some town to some other town, print "Send Kurdy" instead. Put an empty line after each test case.

 Sample Input Sample output `250 010 010 1013 1013 1420 010 1` `Case #1:25.0000Case #2:Send Kurdy`

Problemsetter: Igor naverniouk

Uva10803_thunder Mountain (Short Circuit) (graph theory)

Related Keywords:

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.