I find all pairs distance( include S and A )
and use Prim to find MST, minimum cost
in my method...S and A are treat as the same.
but WA..
is there any tricky??
or I misunderstand something ??
please help ~~ thank you
![:)](./images/smilies/icon_smile.gif)
Moderator: Board moderators
Code: Select all
#####
#AAA###
# A#
# S ###
# #
#AAA###
#####
Code: Select all
and why it said , "That is, if the original group walks five steps, then splits into two groups each walking three steps, the total distance is 11=5+3+3. " ?
Code: Select all
#####
#ABA###
# A#
# ###
# #
#ABA###
#####
Code: Select all
#####
#B B###
# A#
# ###
# #
#B B###
#####
Code: Select all
6 5
#####
#A#A##
# # A#
#S ##
#####
I think Prim algorithm is better than kruskal in this problem.Faizur wrote:I use bfs to get the distance btw them.and then i construct kruskal mst with them.But i recieved time limit exceed. I get accepted with my kruskal implementation in other mst problems.Is there any other faster algorithm to find the shortest distance in a maze.Help me...