목록2024/04/30 (1)
득이공간

문제풀이 다익스트라 알고리즘을 이용해서 푸는 문제입니다.(1,1) -> (n,m)으로 이동하되, 인접 노드 탐색 시 priority_queue(최소힙) 자료구조를 이용해서큐에 들어오는 노드 중 벽을 부수는 비용이 가장 적은 노드부터 탐색하도록 했습니다.그리고 인접 노드의 최소비용 배열의 값을 갱신해주도록 해서 풀었습니다.코드#include #include #include #include using namespace std;typedef pair p;typedef pair pp;const int Inf = INT_MAX;const int DX[4] = { -1, 0, 1, 0 };const int DY[4] = { 0, -1, 0, 1 };int N, M;bool IsWall[100][100];int Co..
PS/알고리즘 문제풀이
2024. 4. 30. 17:20