int get_grid(int x, int y)
{
- if (x == 0 && y == 0)
- return 0;
int r = grid[y%maxy][x%maxx] + y/maxy + x/maxx;
- while (r > 9)
- r -= 9;
+ if (r > 9)
+ return r % 9;
return r;
}
int alt = dist[u.y][u.x] + get_grid(v->key.x, v->key.y);
if (alt < dist[v->key.y][v->key.x]) {
dist[v->key.y][v->key.x] = alt;
+ //Reinsert with in correct position
HASH_DELETE(hh, q, v);
HASH_ADD_INORDER(hh, q, key, sizeof(struct point), v, qcmp);
}