## 10525 - New to Bangladesh?

Moderator: Board moderators

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea
I think you should remove "printf("\n");" at the very first line of each case..

aha2007
New poster
Posts: 10
Joined: Sun Jan 21, 2007 10:38 am
thanks helloneo , i got acceepted.

MRH
Learning poster
Posts: 51
Joined: Mon Aug 11, 2008 9:09 pm

### Re: 10525 - New to Bangladesh

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.

calicratis19
Learning poster
Posts: 76
Joined: Mon Jul 21, 2008 8:50 am
Contact:

### Re: 10525 - New to Bangladesh

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.
Heal The World

asraful.ruet
New poster
Posts: 5
Joined: Wed Aug 11, 2010 8:52 am

### Re: 10525 - New to Bangladesh

I am getting WA .

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;
}

``````

food.cafe
New poster
Posts: 1
Joined: Sat Mar 02, 2013 7:33 am

### Re: 10525 - New to Bangladesh

i feel that out put block spacing is not as per the specification.