일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- VR
- 그리디 알고리즘
- 스택
- 투 포인터
- BFS
- DFS
- 유니티
- 문자열
- 재귀
- 다익스트라
- 우선순위 큐
- 백준
- 수학
- 알고리즘
- XR Interaction Toolkit
- Team Fortress 2
- ue5
- 트리
- 다이나믹 프로그래밍
- c++
- 유니온 파인드
- 백트래킹
- 그래프
- Unreal Engine 5
- 시뮬레이션
- 누적 합
- 정렬
- 브루트포스
- 자료구조
- 구현
- Today
- Total
목록벽 부수고 이동하기 C++ (3)
1일1알

bfs #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using int64 = long long; int n, m, k; int dRow[4] = { -1,0,1,0 }; int dCol[4] = { 0,1,0,-1 }; struct Info { int row; int col; int breakCnt; int moveCnt; }; vector board; vector found; int main() { ios_base::sync_with_std..

벽이 있는 위치에서 상하좌우를 검사하면서 빈 공간이 얼마나 이어져있는지 구해야 한다. 그런데 매번 bfs로 검사하면 시간이 오래 걸리기 때문에 한번 방문해서 이어진 곳은 따로 표시를 해둬서 다음번에 방문할때는 표시해둔 값만 더해주면 된다. 그리고 주의해야할점이 하나 더 있는데, 만약 벽에서 위쪽 빈공간과 오른쪽 빈공간이 이어져있다면 거리를 두번 더하기 때문에 이 부분을 잘 처리해야 한다. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using int64 = ..

동일한 지점에 늦게 도착하더라도 벽을 부술 수 있는 기회가 남아있으면 벽을 부수지 못하는 먼저 도착한 경우보다 먼저 목적지까지 도달할 수 있기 때문에 방문 여부를 기록하는 배열을 벽을 부술 수 있는 상태에서 방문한 것과 부수지 못하는 상태에서 방문한 것 두 가지로 나눠서 문제를 해결하였다. #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; struct Info { int row; int col; int dist; int chance; }; int dRow[..