/* * @(#) msu98_a.c - Problem 'A' ("Cockroach") solution * of the ACM Programming Contest at the MSU in 1998. * (c) 1998 Ivan Maidanski http://ivmai.chat.ru * Freeware program source. All rights reserved. ** * Language: ANSI C * Tested with: Borland C++ v3.1 * Last modified: 1998-10-07 22:10:00 GMT+04:00 */ /* Input data file: a.dat */ #include /* malloc(), free() */ #include /* FILE, fopen(), fscanf(), printf() */ #include /* sqrt() */ #define N 50 #define INFINITY (1.0/0) int n,m; int x1[N],y1[N],x2[N],y2[N]; int xp[2+4*N],yp[2+4*N]; float *pd[2+4*N]; void adjcoord(int *a, int *b) { int t; if (*a>*b) { t=*a; *a=*b; *b=t; } } int isinner(int x, int y) { int i; for (i=0;idcur) pd[i][j]=pd[j][i]=dcur,t++; while (t); if (pd[0][1]<+INFINITY) printf("Minimal distance is %1.2f.\n",pd[0][1]); else printf("Target is unreachable.\n"); for (i=0;i