10803 - Thunder Mountain

All about problems in Volume 108. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 10803 - Thunder Mountain

Post by helloneo »

Try this case..

Code: Select all

1
4
0 0
1 0
20 0
21 0
My output is..

Code: Select all

Case #1:
Send Kurdy

aansu
New poster
Posts: 3
Joined: Wed Oct 13, 2010 1:42 pm

Re: 10803 - Thunder Mountain

Post by aansu »

It is passing all the test cases give here! can someone find the error please!!!

Code: Select all

using namespace std;
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<limits>
#include<cmath>
#define LLU long long unsigned int
#define LLD long long double
#define FOR(i,N) for(int i=0;i<(N);i++)
int NO=1,p,cases,N,val[105][2],pred[105][105];
double ans,tmp,dist[105][105],M_DBL=100000.0;
int distance(int arr1[2],int arr2[2])
{
    int x=(arr1[0]-arr2[0]),y=(arr1[1]-arr2[1]);
    return x*x+y*y;
}

void path(int i,int j)
{
    if(pred[i][j]==-1)
    {
        cout<<i+1<<" "<<j+1<<" ";
        if(dist[i][j]>ans)
        ans=dist[i][j];
    }
    else
    {
        path(i,pred[i][j]);
        path(pred[i][j],j);
    }
}
int main()
{

    cin>>cases;
    while(cases--)
    {
        cin>>N;
        FOR(i,N)
        cin>>val[i][0]>>val[i][1];
        FOR(i,N)
        for(int j=0;j<=i;j++)
        {
            pred[i][j]=-1;
            if(i==j) continue;
            p=distance(val[i],val[j]);
            if(p<=100)
            {
                dist[i][j]=dist[j][i]=(double)sqrt(p);
            }
            else
            dist[j][i]=dist[i][j]=M_DBL;
        }
        FOR(i,N)
        dist[i][i]=0.0;
        FOR(k,N)
        FOR(i,N)
        FOR(j,N)
        {
             tmp=dist[i][k]+dist[k][j];
             if(tmp<dist[i][j])
             {
                 dist[i][j]=tmp;
                 pred[i][j]=k;
             }
        }
//        FOR(i,N)
//        {
//            FOR(j,N)
//            cout<<dist[i][j]<<" ";
//            cout<<"\n";
//        }
        double maxa=-1;
        bool found = false;
        FOR(i,N)
        {
            FOR(j,N)
            {
                if(i!=j)
                if(maxa<dist[i][j] && dist[i][j]<M_DBL-1)
                {
                    maxa=max(maxa,dist[i][j]);
                    found=true;
                }
            }
        }
        if(NO>1) cout<<endl;
        cout<<"Case #"<<NO++<<":"<<endl;
        if(!found)
        cout<<"Send Kurdy\n";
        else //if(dist[0][N-1]*dist[0][N-1]<=100)
        {
            printf("%.4lf\n",maxa);
        }
    }
}

shahidul_brur
New poster
Posts: 12
Joined: Sun Sep 20, 2015 12:33 pm

Re: 10803 - Thunder Mountain

Post by shahidul_brur »

Read the problem ddescription carefully. It says,
Put an
empty line after each test case.
But you are putting an empty line only between cases.
Post Reply

Return to “Volume 108 (10800-10899)”