388 - Galactic Import

All about problems in Volume 3. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
shihabrc
New poster
Posts: 49
Joined: Sun Sep 18, 2005 10:20 am
Location: CSE,BUET
Contact:

388 - Galactic Import

Post by shihabrc »

Can someone gettin AC in this prob give me some I/O. I cann't understand Why my code is givin WA.

-Shihab
Shihab
CSE,BUET

Mohammad Mahmudur Rahman
Experienced poster
Posts: 154
Joined: Sat Apr 17, 2004 9:34 am
Location: EEE, BUET

Post by Mohammad Mahmudur Rahman »

Try these cases -

Code: Select all

7
A 3.64 BCD*
B 3.77 A
C 6.9 ADE
D 8.84 ACG
E 3.52 C*
G 0.97 D
H 2.38 *
5
A 4.76 MX
M 9.63 *AG
G 1.59 MD
X 6.78 A*D
D 6.04 GX
2
B 4.4 *A
A 4.4 *B
1
C 0.01 *
4
A 8.99 BCD
B 6.98 *ACD
C 0.73 DBA
D 6.88 ABC
The output should be

Code: Select all

Import from D
Import from M
Import from A
Import from C
Import from A
You should never take more than you give in the circle of life.

shihabrc
New poster
Posts: 49
Joined: Sun Sep 18, 2005 10:20 am
Location: CSE,BUET
Contact:

Post by shihabrc »

mahmud vai, thanks 4 the I/0s. My code has passed these I/Os and also the ones I made. But not getting AC. Here's my code:

Code: Select all

//code removed after getting AC
Last edited by shihabrc on Wed Jan 04, 2006 10:20 pm, edited 1 time in total.
Shihab
CSE,BUET

Mohammad Mahmudur Rahman
Experienced poster
Posts: 154
Joined: Sat Apr 17, 2004 9:34 am
Location: EEE, BUET

Post by Mohammad Mahmudur Rahman »

1. Your BFS implementation is not correct. You can't make sure that a vertex will not be discovered more than once by simply deleting the tree edges while traversing. Try using a color array instead. While in BFS, only enque the nodes with an UNVISITED color.

2. You're adjacency matrix actually has V+1 nodes (the V planets & 1 for earth). But you're code is dealing with V nodes. Change some of the for loops to (i=0;i<v;i++) to (i=0;i<=v;i++) as necessary.
You should never take more than you give in the circle of life.

shihabrc
New poster
Posts: 49
Joined: Sun Sep 18, 2005 10:20 am
Location: CSE,BUET
Contact:

Post by shihabrc »

Thanx a lot Mahmud vai. I really missed that loop. I've got AC now.And i'll be careful about not revisiting a node in future.

-Thanx.
Shihab
Shihab
CSE,BUET

Mohammad Mahmudur Rahman
Experienced poster
Posts: 154
Joined: Sat Apr 17, 2004 9:34 am
Location: EEE, BUET

Post by Mohammad Mahmudur Rahman »

Nice to know that you've got AC. :)
You should never take more than you give in the circle of life.

Raiyan Kamal
Experienced poster
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh
Contact:

Post by Raiyan Kamal »

can someone explain to me the significance of '*' in this problem ?

Raiyan Kamal
Experienced poster
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh
Contact:

Post by Raiyan Kamal »

Never mind, I've figured it by myself. Sometimes you have to face two problems in one. First you convert the fairy tale or sci-fi story like thing to an understandable version, then solve the real thing. It makes things more interesting though.

Post Reply

Return to “Volume 3 (300-399)”