ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

Who is Fechete Dan Ionut[dany]? What program had he wrote?
Posted by Danilchenko Anton 10 Nov 2002 17:59
I am already waiting more than hour.
Re: Who is Fechete Dan Ionut[dany]? What program had he wrote?
Posted by Fechete Dan Ionut[dany] 10 Nov 2002 19:17
I am Fechete Dan Ionut[dany]
And this is my program for problem 1205
#include <stdio.h>
#include <math.h>
int i,j,n,m,k;
int din[202];
double v[202][202];
/*the distance */
double dist(double x1,double y1,double x2,double y2)
{
return sqrtl(powl(labs(x1-x2),2)+powl(labs(y1-y2),2));
}
/*read the input*/
void readdata()
{
FILE *f=stdin;
double feet,under;
fscanf(f,"%lf %lf",&feet,&under);
fscanf(f,"%d",&n) ;
double coord[202][2];
for (i=1;i<=n;i++)
 {
 fscanf(f,"%lf %lf",&coord[i][0],&coord[i][1]);
 }
char c[202][202];
for (i=0;i<=n+1;i++)
 for (j=0;j<=n+1;j++) c[i][j]=0;
fscanf(f,"%d",&j);
while (j!=0)
 {
 fscanf(f,"%d",&k);
 c[j][k]=1;
 c[k][j]=1;
 fscanf(f,"%d",&j);
 }
fscanf(f,"%lf %lf %lf %lf",&coord[0][0],&coord[0][1],&coord[n+1]
[0],&coord[n+1][1]);
for (i=0;i<=n+1;i++)
 for (j=0;j<=n+1;j++)
  if (i==j) v[i][j]=2000000000;
  else
   {
   v[i][j]=dist(coord[i][0],coord[i][1],coord[j][0],coord[j][1]);
   if (c[i][j]==1) v[i][j]/=under;
   else v[i][j]/=feet;
   }
fclose (f);
}
/*write path*/
void scrie(int i)
{
if (din[i]!=0) scrie(din[i]);
printf("%d ",i);
}
void main()
{
readdata();
double d[202];
int s[202];
int c[202];
/*dijkstra*/
c[0]=0;
din[0]=0;
d[0]=0;
s[0]=0;
for (i=1;i<=n+1;i++) {d[i]=2000000000;s[i]=0;c[i]=0;din[i]=0;}
for (i=1;i<=n+1;i++)
 {
 j=0;
 while (s[j]==1) j++;
 int min=j;
 for (j=min+1;j<n+1;j++)
  if (d[j]<d[min]&&s[j]!=1) min=j;
 for (j=1;j<=n+1;j++)
  if (d[j]>d[min]+v[min][j])
   {
   d[j]=d[min]+v[min][j];
   c[j]=c[min]+1;
   din[j]=min;
   }
 s[min]=1;
 }
printf("%.7lf\n",d[n+1]);
printf("%d ",c[n+1]-1);
if (din[n+1]!=0)scrie(din[n+1]);
}
Re: Who is Fechete Dan Ionut[dany]? What program had he wrote?
Posted by Fechete Dan Ionut[dany] 10 Nov 2002 19:22
I am Fechete Dan Ionut[dany]
And this is my program for problem 1205
#include <stdio.h>
#include <math.h>
int i,j,n,m,k;
int din[202];
double v[202][202];
/*the distance */
double dist(double x1,double y1,double x2,double y2)
{
return sqrtl(powl(labs(x1-x2),2)+powl(labs(y1-y2),2));
}
/*read the input*/
void readdata()
{
FILE *f=stdin;
double feet,under;
fscanf(f,"%lf %lf",&feet,&under);
fscanf(f,"%d",&n) ;
double coord[202][2];
for (i=1;i<=n;i++)
 {
 fscanf(f,"%lf %lf",&coord[i][0],&coord[i][1]);
 }
char c[202][202];
for (i=0;i<=n+1;i++)
 for (j=0;j<=n+1;j++) c[i][j]=0;
fscanf(f,"%d %d",&j,&k);
while (j!=0)
 {
 c[j][k]=1;
 c[k][j]=1;
 fscanf(f,"%d %d",&j,&k);
 }
fscanf(f,"%lf %lf %lf %lf",&coord[0][0],&coord[0][1],&coord[n+1]
[0],&coord[n+1][1]);
for (i=0;i<=n+1;i++)
 for (j=0;j<=n+1;j++)
  if (i==j) v[i][j]=2000000000;
  else
   {
   v[i][j]=dist(coord[i][0],coord[i][1],coord[j][0],coord[j][1]);
   if (c[i][j]==1) v[i][j]/=under;
   else v[i][j]/=feet;
   }
fclose (f);
}
/*write path*/
void scrie(int i)
{
if (din[i]!=0) scrie(din[i]);
printf("%d ",i);
}
void main()
{
readdata();
double d[202];
int s[202];
int c[202];
/*dijkstra*/
c[0]=0;
din[0]=0;
d[0]=0;
s[0]=0;
for (i=1;i<=n+1;i++) {d[i]=2000000000;s[i]=0;c[i]=0;din[i]=0;}
for (i=1;i<=n+1;i++)
 {
 j=0;
 while (s[j]==1) j++;
 int min=j;
 for (j=min+1;j<n+1;j++)
  if (d[j]<d[min]&&s[j]!=1) min=j;
 for (j=1;j<=n+1;j++)
  if (d[j]>d[min]+v[min][j])
   {
   d[j]=d[min]+v[min][j];
   c[j]=c[min]+1;
   din[j]=min;
   }
 s[min]=1;
 }
printf("%.7lf\n",d[n+1]);
printf("%d ",c[n+1]-1);
if (din[n+1]!=0)scrie(din[n+1]);
}
Re: Who is Fechete Dan Ionut[dany]? What program had he wrote?
Posted by Fechete Dan Ionut[dany] 10 Nov 2002 19:23
I am Fechete Dan Ionut[dany]
And this is my program for problem 1205
#include <stdio.h>
#include <math.h>
int i,j,n,m,k;
int din[202];
double v[202][202];
/*the distance */
double dist(double x1,double y1,double x2,double y2)
{
return sqrtl(powl(labs(x1-x2),2)+powl(labs(y1-y2),2));
}
/*read the input*/
void readdata()
{
FILE *f=stdin;
double feet,under;
fscanf(f,"%lf %lf",&feet,&under);
fscanf(f,"%d",&n) ;
double coord[202][2];
for (i=1;i<=n;i++)
 {
 fscanf(f,"%lf %lf",&coord[i][0],&coord[i][1]);
 }
char c[202][202];
for (i=0;i<=n+1;i++)
 for (j=0;j<=n+1;j++) c[i][j]=0;
fscanf(f,"%d %d",&j,&k);
while (j!=0)
 {
 c[j][k]=1;
 c[k][j]=1;
 fscanf(f,"%d %d",&j,&k);
 }
fscanf(f,"%lf %lf %lf %lf",&coord[0][0],&coord[0][1],&coord[n+1]
[0],&coord[n+1][1]);
for (i=0;i<=n+1;i++)
 for (j=0;j<=n+1;j++)
  if (i==j) v[i][j]=2000000000;
  else
   {
   v[i][j]=dist(coord[i][0],coord[i][1],coord[j][0],coord[j][1]);
   if (c[i][j]==1) v[i][j]/=under;
   else v[i][j]/=feet;
   }
fclose (f);
}
/*write path*/
void scrie(int i)
{
if (din[i]!=0) scrie(din[i]);
printf("%d ",i);
}
void main()
{
readdata();
double d[202];
int s[202];
int c[202];
/*dijkstra*/
c[0]=0;
din[0]=0;
d[0]=0;
s[0]=0;
for (i=1;i<=n+1;i++) {d[i]=2000000000;s[i]=0;c[i]=0;din[i]=0;}
for (i=1;i<=n+1;i++)
 {
 j=0;
 while (s[j]==1) j++;
 int min=j;
 for (j=min+1;j<n+1;j++)
  if (d[j]<d[min]&&s[j]!=1) min=j;
 for (j=1;j<=n+1;j++)
  if (d[j]>d[min]+v[min][j])
   {
   d[j]=d[min]+v[min][j];
   c[j]=c[min]+1;
   din[j]=min;
   }
 s[min]=1;
 }
printf("%.7lf\n",d[n+1]);
printf("%d ",c[n+1]-1);
if (din[n+1]!=0)scrie(din[n+1]);
}
faint.Do you know why your problem crashed the judge system?
Posted by aaakkk 10 Nov 2002 21:06
Re: faint.Do you know why your problem crashed the judge system?
Posted by Fechete Dan Ionut[dany] 11 Nov 2002 04:34
> Nope