목록Algorithm (154)
cgy12306
// https://www.acmicpc.net/problem/1219 // 오민식의 고민 #include #include #include #include using namespace std; int N, M, from, to, INF = -999999999; long long minCost[51]; int map[51]; bool visited[51], Geecheck[51]; bool check = false; vector Edge; void bellman(int start) { fill(minCost, minCost + N + 1, INF); minCost[start] = map[start]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) {..
// https://www.acmicpc.net/problem/1865 // 웜홀 #include #include #include using namespace std; int T, N, M, W; vector Edge; long long minCost[502]; int INF = 999999999; bool bellman(int start) { fill(minCost, minCost + N + 1, INF); minCost[start] = 0; for (int i = 0; i < N; i++) { for (int j = 1; j nextCost) { minCost[next] = nextCost; if (i == N - 1) return true; } } } } return false; } int main..
// https://www.acmicpc.net/problem/1956 // 운동 #include #include #include using namespace std; int map[402][402]; int V, E; int INF = 999999999; void floyd() { for(int k = 1; k > E; for (int i = 0; i > from >> to >> cost; map[from][to] = cost; } floyd(); int Min = INF; for (int i = 1; i
// https://www.acmicpc.net/problem/10159 // 저울 #include using namespace std; int N, M; bool map[102][102]; void floyd() { for (int k = 1; k > M; for (int i = 0; i > from >> to; map[from][to] = true; } floyd(); int cnt = 0; for (int i = 1; i
// https://www.acmicpc.net/problem/1261 // 알고스팟 #include #include #include #include #include #include using namespace std; int N, M, INF = 999999999; int map[102][102], minCost[102][102]; int dx[] = { -1, 1, 0, 0 }; int dy[] = { 0, 0, -1, 1 }; void dijkstra() { fill(minCost[0], minCost[102], INF); priority_queue pq; minCost[1][1] = 0; pq.push(make_tuple(map[1][1], 1, 1)); while (!pq.empty()) { i..
// https://www.acmicpc.net/problem/4485 // 녹색 옷 입은 애가 젤다지? #include #include #include #include #include using namespace std; int N, map[126][126], INF = 999999999, minCost[126][126]; int dx[] = { -1, 1, 0 ,0 }; int dy[] = { 0, 0, -1, 1 }; bool visited[126][126]; void dijkstra(int x, int y) { fill(minCost[0], minCost[126], INF); priority_queue pq; minCost[x][y] = map[x][y]; pq.push(make_tuple(-ma..
// https://www.acmicpc.net/problem/1504 // 특정한 최단 경로 #include #include #include #include using namespace std; int N, E, INF = 999999999; int minCost[802]; vector Edge; void dijkstra(int start) { fill(minCost, minCost + N + 1, INF); priority_queue pq; pq.push(make_pair(0, start)); minCost[start] = 0; while (!pq.empty()) { int cost = -pq.top().first; int current = pq.top().second; pq.pop(); if (mi..
// https://www.acmicpc.net/problem/1238 // 파티 #include #include #include #include #include using namespace std; int N, M, X, Max = 0, INF = 999999999, ans = 0; int minCost[1002]; vector Edge; void dijkstra(int start) { fill(minCost, minCost + N + 1, INF); priority_queue pq; pq.push(make_pair(0, start)); minCost[start] = 0; while (!pq.empty()) { int cost = -pq.top().first; int current = pq.top()...