10525 - New to Bangladesh?
Moderator: Board moderators
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.
THANKS IN ADVANCE.
BUT AGAIN & AGAIN...............................WA
PLZ ANY ONE SAVE ME FROM THIS PROBLEM .
I BECOME TRIED.
THANKS IN ADVANCE.
-
- Learning poster
- Posts: 76
- Joined: Mon Jul 21, 2008 8:50 am
- Location: SUST,SYLHET,BANGLADESH.
- 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.
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
-
- New poster
- Posts: 5
- Joined: Wed Aug 11, 2010 8:52 am
Re: 10525 - New to Bangladesh
I am getting WA .
Please Help .
Thanks in advance .
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
i feel that out put block spacing is not as per the specification. ![:)](./images/smilies/icon_smile.gif)
![:)](./images/smilies/icon_smile.gif)