Thank you very much Shalin and Wade. Your ideas are really nice. I will
give them a try and give u feedback.
wade, the timelimit was 10 seconds, my solution took 10.025 seconds.
shalinmangar wrote:
> The low input size constraints (max size of the graph is 40*40) suggest
> that a brute force DFS
The low input size constraints (max size of the graph is 40*40) suggest
that a brute force DFS to find the connected components may work fine.
Each square (x,y) is a node with edges to each reachable square {
{x+1,y), {x,y+1], {x-1,y}, {x,y-1} }. Maintain a boolean matrix to keep
track of visited
Farhan wrote:
> Guys,
>
> I was just trying to solve the problem "Mountain Village" in acm
> problemset site. I figured out a way to solve it but it turned out to
> be extremely inefficient. It exceeded the time limit. Can anyone give
> me an idea about how to solve it with better technique and b
Farhan wrote:
> Guys,
>
> I was just trying to solve the problem "Mountain Village" in acm
> problemset site. I figured out a way to solve it but it turned out to
> be extremely inefficient. It exceeded the time limit. Can anyone give
> me an idea about how to solve it with better technique and be