http://acm.hdu.edu.cn/showproblem.php?pid=1875
I just want to ask why it has been wrong, ask the great God of the way to teach!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace Std;
int C,k,cou;
Double shortest;
struct p{
int x;
int y;
}POINT[110];
BOOL visit[110];
struct graph{
int la,lb;
Double JL;
}G[5050];
Double Hpy (P a,p b) {
return sqrt (POW (a.x-b.x,2) +pow (a.y-b.y,2));
}
int cmp (Graph a,graph b) {
Return a.jl<b.jl;
}
void Kruskal () {
Sort (g,g+k,cmp);
int i;
memset (visit,0,sizeof (visit));
shortest=0; cou = 0;
for (I=0;i<k;++i) {
int p,q;
p=g[i].la,q=g[i].lb;
if (!visit[p]| |! Visit[q]) {
SHORTEST+=G[I].JL;
Visit[p]=1;
Visit[q]=1;
cou++;
}
}
printf ("%d%.1lf\n", cou,shortest);
}
int main () {
int t,i,j;
scanf ("%d", &t);
while (t--) {
scanf ("%d", &c);
for (I=1;i<=c;++i)
scanf ("%d%d", &point[i].x,&point[i].y);
k=0; Double U;
for (I=1;i<c;++i) {
for (J=I+1;J<=C;++J) {
U=hpy (Point[i],point[j]);
printf ("------%.2lf\n", u);
if ((u-10) >=1e-7&& (1000-u) >=1e-7)
if (u>=10.000000&&u<=1000.000001) {
G[k].jl=hpy (Point[i],point[j]);
G[k].la=i,g[k].lb=j;
k++;
printf ("%d,%d,%.2lf\n", G[K].LA,G[K].LB,G[K].JL);
}
}
}
Kruskal ();
if (cou!= (c-1))
printf ("oh!\n");
Else
printf ("%.1lf\n", shortest*100);
}
return 0;
}
Hdoj-1875-unblocked works re-continued