Page 4 of 4

Posted: Sun Mar 04, 2007 7:32 am
by helloneo
I think you should remove "printf("\n");" at the very first line of each case..

Posted: Sun Mar 04, 2007 8:43 am
by aha2007
thanks helloneo , i got acceepted.

Re: 10525 - New to Bangladesh

Posted: Fri Jun 05, 2009 6:39 pm
by MRH
I TRY TO SLOVED THIS PROBLEM SEVERAL TIME ,EVEN ALL POST OF BOARD INPUT PASS MY PROGRAM .
BUT AGAIN & AGAIN...............................WA

PLZ ANY ONE SAVE ME FROM THIS PROBLEM .
I BECOME TRIED.

THANKS IN ADVANCE.

Re: 10525 - New to Bangladesh

Posted: Mon Oct 26, 2009 8:11 pm
by calicratis19
this is a very simple floyd warshell problem. implementing almost the standard code can get you ac.
only special case is that, same edge can repeat with random values in input. so you have to take the minimum time and distance .
if you still cant get ac then you can post your code .
thank you.

Re: 10525 - New to Bangladesh

Posted: Sun Sep 12, 2010 10:31 am
by asraful.ruet
I am getting WA .
Please Help .
Thanks in advance .

Code: Select all

#include<stdio.h>
#define N 252
#define INF 1000000000

int  main()
{
int t,q;
scanf("%d",&t);

for(q=1;q<=t;++q)
{
int mat[N][N], cat[N][N], n, e,c,d;

scanf("%d%d", &n, &e);

for(int i=1; i<=n; i++)
 for(int j=1; j<=n; j++){
  mat[i][j] = mat[j][i] = INF;
  cat[i][j] = cat[j][i] = INF;

}

for(int i,j, k=1; k<=e; k++)
{
scanf("%d%d%d%d", &i, &j, &c, &d);

if( mat[i][j]==INF || mat[i][j]>c ||( mat[i][j]==c && cat[i][j]> d )){
  mat[i][j] = mat[j][i] = c;
  cat[i][j] = cat[j][i] = d;

  }

}



for(int k=1; k<=n; k++){
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
       if(mat[i][k]!=INF && mat[k][j]!=INF && i!=j){

            if(mat[i][k]+mat[k][j] < mat[i][j]){
               mat[i][j] = mat[i][k] + mat[k][j];
               cat[i][j] = cat[i][k] + cat[k][j];
              }

          else if(mat[i][k]+mat[k][j] == mat[i][j]){
              if(cat[i][k]+cat[k][j] < cat[i][j])
                 mat[i][j] = mat[i][k] + mat[k][j];
                 cat[i][j] = cat[i][k] + cat[k][j];
                 }

       }
    }
  }
}

int p;
scanf("%d",&p);

while(p--){
  scanf("%d%d",&c,&d);

  if(c==d)
   printf("Distance and time to reach destination is 0 & 0.\n");

  else{
    if(mat[c][d]!=INF)
       printf("Distance and time to reach destination is %d & %d.\n",cat[c][d],mat[c][d]);
    else
       printf("No Path.\n");

  }
}

if(q!=t)
 printf("\n");

}
return 0;
}






Re: 10525 - New to Bangladesh

Posted: Sat Mar 02, 2013 7:35 am
by food.cafe
i feel that out put block spacing is not as per the specification. :)