최단경로2 Floyd-Warshall #include #include #define INF 1e9 #define NODES 101 using namespace std; int N, M; // 노드 간선 수 int dist[NODES][NODES]; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cin >> N >> M; for (int i = 1; i > v >> w; dist[u][v] = min(dist[u][v], w); } for (int k = 1; k 2020. 8. 15. Dijkstra struct Dijkstra { using elem = pair; const ll INF = 2e18; int vol; vector dup; vector adj; Dijkstra(int _vol) { vol = _vol + 1; dup.resize(vol, INF); adj.resize(vol); } void connect(int u, int v, ll w) { adj[u].push_back({w, v}); } void run(int base) { priority_queue que; que.push({0, base}); dup[base] = 0; while (!que.empty()) { auto [cw, id] = que.top(); que.pop(); if (dup[id] < cw) continue; .. 2020. 8. 6. 이전 1 다음