I’m writing a solution for a simple programming problem, but I can’t get map::find() to work. I am using maps to mark visited vertices when using BFS. I know I could use some other data structure, such as a 2D bool array, but I’m just really eager to make it work with maps.
Here’s my code: http://pastebin.com/mANej4vp
The problem is that visited[tempR] is always true, even though the tempR position hasn’t been visited yet. And the visited.size() is 1, but it responds to both the visited[now] and visited[tempR] as true; while tempR is not equal to now.
Duom.in file should contain this: http://pastebin.com/L7qMG0bd
Do you have any idea why is this happening?
Your
operator<andoperator==are inconsistentfor two positions
b1is true, sob2must be true by definition, but it’s not.In other words, rewrite your
operator<to do proper comparison, not justHx