본문 바로가기

Algorithm/Graph - Shrotest Path

(6)
PROMISES #include #include #include #define MAX_V 200 #define MAX_M 1000 #define MAX_N 1000 #define INF 99999 using namespace std; struct path_info { int a; int b; int c; }typedef path_info; int adj[MAX_V][MAX_V]; vector new_adjs; int shortest_adj[MAX_V][MAX_V]; int shortest_new_adj[MAX_V][MAX_V]; int solve(int v); void floyd(int param_adj[MAX_V][MAX_V], int v); int main() { int caseNum; cin >> caseNum; ..
DRUNKEN #include #include #include #define MAX_V 500 #define INF 99999 using namespace std; // first - vertex, second - cost int adj[MAX_V][MAX_V]; int W[MAX_V][MAX_V]; vector order; int delay[MAX_V]; int v, e; void solve(); int main() { cin >> v >> e; int delayInput; for (int i = 0; i > delayInput; delay[i] = delayInput; } for (int i = 0; i < v; i++) { order.push_back(make_pair..
TIMETRIP #include #include #include #define MAX_V 100 #define INF 99999 using namespace std; // first - vertex, second - cost vector adj[MAX_V]; bool reachable[MAX_V][MAX_V]; void floyd(int vCnt); int bellman2(int src, int target, int vCnt); int main() { int caseNum; cin >> caseNum; for (int cIter = 0; cIter > g >> w..
NTHLON #include #include #include using namespace std; #define MAX_V 410 #define INF 99999 const int START = 401; vector adj[MAX_V]; int vertex(int delta); int solve(vector & a, vector & b); vector dijkstra(const int src); int main() { int caseNum; cin >> caseNum; for (int cIter = 0; cIter > n; int aTime, bTime; for (int nIter = 0; nIter < n; nIter++) { ci..
FIRETRUCKS #include #include #include using namespace std; #define MAX_V 1001 #define INF 99999 vector truckLocations; vector fireLocations; // first - adj vertex, second - cost vector adj[MAX_V]; vector dijkstraModified(); int main() { int caseNum; cin >> caseNum; for (int cIter = 0; cIter < caseNum; cIter++) { truckLocations.clear(); fireLocations.clear(); for (int i = 0; i < MAX_V; i++) { adj[i].clear()..
ROUTING #include #include #include using namespace std; #define MAX_V 10000 #define INF 99999 vector adj[MAX_V]; vector dijkstra(int v, int src); int main() { int caseNum; cin >> caseNum; for (int cIter = 0; cIter > n >> m; int start, end; float cost; for (int i = 0; i > start >> end >> cost; adj[start].push_back(make_pair(end, cost)); } vector dist ..