백준 1012번 C++
#include #include using namespace std; const int MAX = 51; int n, m, k; int lettuce[MAX][MAX]; int indexs; int visited[MAX][MAX]; struct Move { int x, y; }; Move mv[4] = { {-1,0}, {1,0}, {0,1}, {0,-1} }; void dfs(int i, int j) { for (int k = 0; k = 0 && movei = 0 && movej < n && lettuce[movei][movej] && visite..
2019. 8. 8.
백준 7576번 C++
#include #include #include using namespace std; const int MAX = 1001; int n, m; int tomato[MAX][MAX]; queue t; struct Move { int x, y; }; Move mv[4] = { {1,0}, {-1,0}, {0,1}, {0,-1} }; void bfs(int i,int j) { for (int k = 0; k = 0 && movei = 0 && movej < n && tomato[movei][movej] == 0) { tomato[movei][movej] =..
2019. 8. 8.
백준 2667번 C++
#include #include #include using namespace std; const int MAX = 26; int n, index = 1, cnt; string s; int apart[MAX][MAX]; int answer[MAX]; struct Move { int x, y; }; Move mv[4] = { {1,0},{-1,0},{0,1},{0,-1} }; void dfs(int i, int j) { cnt++; apart[i][j] = index; for (int k = 0; k = 0 && movei = 0 && movej < n ..
2019. 8. 8.