UVa 929 - Number Maze
/* Accepted Algorithm: Dijkstra The sample of this problem is also solvable using BFS algorithm, but to find minimum the problem is an optimization problem. So, the Dijkstra algorithm is perfect for it. This is straight forward Dijkstra. But, you should visit each position (x, y) as one time to avoid TLE. */ #include<bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define psb push_back #define fast ios_base::sync_with_stdio(false) typedef map<string, int>mpsi; typedef map<int, string>mpis; typedef long long LL; const int high = 1005; const int inf = (1 << 31) - 1; vector<LL>adj[high]; vector<LL>nodelist; int matrix[high][high], visited[high][high], cost[high][high]; int N , M , test; int move_x[] = {1, -1, 0, 0}; int move_y[] = {0, 0, 1, -1}; struct data { int node1, node2, cost; ...