전체 글(334)
-
[BOJ] 7569번 : 토마토
1. problem :https://www.acmicpc.net/problem/7569 2. solution 1 :#include using namespace std; #define X first#define Y second #define Z third int board[102][102][102];int days[102][102][102]; int col, row, height; int dx[6] = { 1,0,-1,0,0,0 };int dy[6] = { 0,1,0,-1,0,0 };int dz[6] = { 0,0,0,0,1,-1 }; bool found = false; queue> Q; // x,y,z를 담기위해 tuple을 이용; int main(void) { ios::sync_with_stdio(0)..
2024.08.14 -
[BOJ] 10026번 : 적록색약
1. problem : https://www.acmicpc.net/problem/10026 2. solution 1 :#include using namespace std;#define X first#define Y second string board[102];int vis[102][102]; int row,col; // row == col;int dx[4] = { 1,0,-1,0 };int dy[4] = { 0,1,0,-1 };int normal_count;int color_count;queue> Q;void bfs(int x, int y,char color) { Q.push({ x,y }); vis[x][y] = 1; while (!Q.empty()) { pair cur = Q.front(); Q..
2024.08.13 -
[BOJ] 1012번 : 유기농 배추
1. problem :https://www.acmicpc.net/problem/1012 2. solution 1 :#include using namespace std; #define X first #define Y second int board[52][52]; int vis[52][52]; int dx[4] = { 1,0,-1,0 };int dy[4] = { 0,1,0,-1 };int T, row, col, K; // test case 수, 세로, 가로, 배추 갯수; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> T; while (T--) { memset(board, 0, sizeof(board)); // 배열 초기화 memset(vi..
2024.08.13 -
[BOJ] 1697번 : 숨바꼭질
1. problem : https://www.acmicpc.net/problem/1697 2. solution 1 :#include using namespace std; int board[200005]; int pos1, pos2; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> pos1 >> pos2; fill(board, board + 200005, -1); queue Q; if (pos1 == pos2) { cout = 0 && board[dx1] == -1) { board[dx1] = board[current] + 1; Q.push(dx1); if (dx1 == pos2) { cout = 0 && board[..
2024.08.13 -
[BOJ] 4179번 : 불!
1. problem : https://www.acmicpc.net/problem/4179 2. solution 1 :#include using namespace std; #define X first #define Y second int rows, cols; string board[1005];int minutes_f[1005][1005];int minutes_j[1005][1005];int dx[4] = { 1,0,-1,0 };int dy[4] = { 0,1,0,-1 };int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> rows >> cols; // board 값 채우기 for (int i = 0; i > board[i]; } // minut..
2024.08.13 -
[BOJ] 7576번 : 토마토
1. problem : https://www.acmicpc.net/problem/7576 2. solution 1 :#include using namespace std;#define X first #define Y second int dx[4] = { 0,1,0,-1 };int dy[4] = { 1,0,-1,0 };int days[1005][1005]; int board[1005][1005]; int rows, cols; int main(void) { ios::sync_with_stdio(0); cin.tie(0); queue> Q; cin >> cols >> rows; // board에 값 입력받기 for (int i = 0; i > board[i][j]; if (board[i][j] == 1..
2024.08.13