Code: Select all
1
4
0 0
1 0
20 0
21 0
Code: Select all
Case #1:
Send Kurdy
Moderator: Board moderators
Code: Select all
1
4
0 0
1 0
20 0
21 0
Code: Select all
Case #1:
Send Kurdy
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);
}
}
}
But you are putting an empty line only between cases.Put an
empty line after each test case.