본문 바로가기

백준 알고리즘/DFS18

백준 미세먼지 안녕 C++ #include #include #include using namespace std; const int MAX = 1001; int r, c, t; int air[MAX][MAX]; int copyair[MAX][MAX]; int copys[MAX][MAX]; vector cleanmachine; struct Move { int x, y; }; Move mv[4] = { {1,0}, {0,1}, {0,-1}, {-1,0} }; void dfs(int i, int j) { int spread = int(copyair[i][j] / 5); int count = 0; for (int k = 0; k < 4; k++) { int movei = i + mv[k].x; int movej = j + mv[k].y; .. 2019. 10. 15.
백준 15683번 C++ #include #include #include #include using namespace std; const int MAX = 9; int office[MAX][MAX]; int n, m; int copyoffice[MAX][MAX]; int answer = 987654321; vector angle; vector camera; vector cameraangle[5]; struct Move { int x, y; }; Move mv[4] = { {-1,0}, {0,1}, {1,0}, {0,-1} }; void copyandmincheck() { int value = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (copyoffice.. 2019. 9. 19.
백준 12100번 C++ #include #include #include using namespace std; const int MAX = 21; int answer = 1; int n; int board[MAX][MAX]; void moveblock(int k) { switch (k) { case 0: for (int i = 0; i = 0; j--) { if (board[j][i] != 0) q.push(board[j][i]); board[j][i] = 0; } int index = n - 1; while (!q.empty()) { int value = q.front(); q.pop(); if (board[index][i] == 0) board[i.. 2019. 9. 19.
백준 2468번 C++ #include #include #include using namespace std; const int MAX = 101;int n;int arr[MAX][MAX];int visited[MAX][MAX];typedef struct {int a, b;}Move;Move mv[4] = { {1,0},{-1,0},{0,1},{0,-1} }; void dfs(int i,int j,int h) {for (int k = 0; k = 0 && mi = 0 && mj h && visited[mi][mj] == -1) {visited[mi][mj] .. 2019. 2. 25.