[BOJ] 2206번 벽 부수고 이동하기 (C++)
https://www.acmicpc.net/problem/2206 2206번: 벽 부수고 이동하기 N×M의 행렬로 표현되는 맵이 있다. 맵에서 0은 이동할 수 있는 곳을 나타내고, 1은 이동할 수 없는 벽이 있는 곳을 나타낸다. 당신은 (1, 1)에서 (N, M)의 위치까지 이동하려 하는데, 이때 최단 경로 www.acmicpc.net #include #include #include using namespace std; int n, m; char map[1001][1001]; int visited[1001][1001][2]; int dx[4] = {-1, 0, 0, 1}; int dy[4] = {0, -1, 1, 0}; bool bfs(int x, int y){ queue q; // {벽 뚫기 여부, {..
[BOJ] 19942번 다이어트 (C++)
https://www.acmicpc.net/problem/19942 19942번: 다이어트 식재료 N개 중에서 몇 개를 선택해서 이들의 영양분(단백질, 탄수화물, 지방, 비타민)이 일정 이상이 되어야 한다. 아래 표에 제시된 6가지의 식재료 중에서 몇 개를 선택해서 이들의 영양분의 각 www.acmicpc.net #include #include using namespace std; struct Ingredient{ int p, f, s, v, c; }; int n, mp, mf, ms, mv; vector v; vector tmp; vector ans; int answer = 987654321; void dfs(int idx, int sp, int sf, int ss, int sv, int sc){ if..