[Baekjoon][20056] 마법사 상어와 파이어볼
출처 - 백준사이트 20056. 마법사 상어와 파이어볼 나의 풀이 해당 문제는 어렵지는 않으며, 몇가지만 고려하면 된다. 맵끼리 이어져 있다는 점. 방향이 모두 짝수이거나 홀수이면 나뉘어지는 파이어볼 방향이 0,2,4,6, 그렇지 않으면 1,3,5,7 위 두사항만 잘 고려한다면 어렵지 않은 문제이다. #include #include #define MAX_SIZE 50 using namespace std; const int dy[] = {-1, -1, 0, 1, 1, 1, 0, -1}; const int dx[] = {0, 1, 1, 1, 0, -1, -1, -1}; typedef struct _FireBall { int dir; int speed; int weight; _FireBall(int dir, ..
2022. 6. 29.
[Baekjoon][14503] 로봇 청소기
출처 - 백준사이트 14503. 로봇 청소기 나의 풀이 #include #include #define MAX_SIZE 50 using namespace std; int N, M, cnt; int map[MAX_SIZE][MAX_SIZE] = {0, }; typedef struct { int x; int y; int dir; } ROBOT; // 각 index는 북 동 남 서일때 다음이동. int dy[] = {0, -1, 0, 1 }; int dx[] = {-1, 0, 1, 0 }; int main () { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); ROBOT robot; cin >> N >> M; cin >> robot.y >> robot.x >> ..
2022. 3. 10.
[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.