본문 바로가기

전체 글96

[Baekjoon][19237] 어른 상어 출처 - 백준사이트 19237. 어른 상어 나의 풀이 #include #include #include #define MAX_SIZE 20 using namespace std; const int dy[] = {0, -1, 1, 0, 0}; const int dx[] = {0, 0, 0, -1, 1}; typedef enum {EMPTY = 0, SHARK, SMELL} State; typedef struct { bool isLife; int dir; pair pos; vector move; } Shark; typedef struct { State state; int shark; int smell; } Info; int N, M, k, result; Info map[MAX_SIZE][MAX_SIZE]; Sh.. 2022. 3. 10.
[Baekjoon][19236] 청소년 상어 출처 - 백준사이트 19236. 청소년 상어 나의 풀이 #include #include using namespace std; const int dy[] = {0, -1, -1, 0, 1, 1, 1, 0, -1}; const int dx[] = {0, 0, -1, -1, -1, 0, 1, 1, 1}; typedef enum State {EMPTY, SHARK, FISH}; typedef struct info { State state; int num; int dir; } Info; Info map[4][4]; int result = 0; void moving_fish(Info (*pmap)[4]) { for (int i=1 ; i 2022. 3. 8.
[Baekjoon][16236] 아기 상어 출처 - 백준사이트 16236. 아기 상어 나의 풀이 이 문제풀때, 머리속에 "아기상어 뚜루루뚜룻~" 노래가 맴도는 순간 집중력 흐트러지니 주의 #include #include #include #define MAX_SIZE 20 using namespace std; typedef struct _shark { int y; int x; } Shark; const int dy[] = {-1, 0, 1, 0}; const int dx[] = {0, -1, 0, 1}; int N; int map[MAX_SIZE][MAX_SIZE]; bool visited[MAX_SIZE][MAX_SIZE] = {false, }; int movingtime, sharkSize, sizeupCnt; int result; Shark .. 2022. 3. 8.
[Baekjoon][14502] 연구소 출처 - 백준사이트 14502. 연구소 나의 풀이 #include #include #include #include #define MAX_SIZE 8 using namespace std; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int N, M, result; int map[MAX_SIZE][MAX_SIZE]; int temp_map[MAX_SIZE][MAX_SIZE]; vector virus; // BFS로 바이러스를 감염시킨다. void BfsVirus() { int after_Wall[MAX_SIZE][MAX_SIZE]; // 벽으로 감싼 후 상황 복사 memcpy(after_Wall, temp_map, sizeof(afte.. 2022. 3. 8.
[Baekjoon][14501] 퇴사 출처 - 백준사이트 14501. 퇴사 나의 풀이 #include using namespace std; int N = 0; int daypay[2][15]; int result; int day, pay; void dfs(int idx) { for (int i=idx ; i= daypay[0][i] && (day + daypay[0][i] N; for (int i=0 ; i> daypay[0][i] >> daypay[1][i]; dfs(0); cout 2022. 3. 8.
[Baekjoon][20061] 모노미노도미노 2 출처 - 백준사이트 20061. 모노미노도미노 2 나의 풀이 블록 입력시 초록색맵과 파란색 맵에 알맞은 위치에 블록이 생성하게 한뒤, 동일한 블록이동 함수를 사용하여 구현. 블록이동 함수는 수평도미노 이동함수, 단일 혹은 수직도미노 이동함수 2개로 구현하였다. 주의해야할 반례, 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 -> 0 0 1 0 옆의 예시처럼 모든 행이 1인 구간이 먼저 삭제 됨을 유의. 1 0 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 1 1 1 0 1 1 1 해당 반례 및 답. 8 3 1 0 3 0 1 1 2 1 1 0 0 3 2 1 3 0 1 1 3 1 answer : 1 2 2 1 14 #include #include #include using n.. 2022. 2. 28.