본문 바로가기
반응형

알고리즘288

[코드트리] 미로 타워 디펜스 (삼성 SW 역량테스트 2021 상반기 오후 2번) 삼성 A형 전체 링크 Codetree 기출문제 링크 https://www.codetree.ai/training-field/frequent-problems/problems/maze-tower-defense 미로 타워 디펜스 문제 풀이는 BOJ 21611 : 마법사 상어와 블리자드와 비슷하지만, 방향의 정의와 점수 산정 방식이 다르다. 이 문제에서 방향은 아래와 같이 정의한다./* →, ↓, ←, ↑ */int drr[] = { 0, 1, 0, -1 };int dcc[] = { 1, 0, -1, 0 }; 그리고 플레이어가 몬스터를 제거할 때, 점수를 추가해야 한다. for (int k = 1; k  전체 코드는 다음과 같다.#include #define MAX (50 + 5)int T;int N, M;int.. 2024. 6. 9.
[코드트리] 나무 타이쿤 (삼성 SW 역량테스트 2021 상반기 오후 1번) 삼성 A형 전체 링크 Codetree 기출문제 링크 https://www.codetree.ai/training-field/frequent-problems/problems/tree-tycoon 나무 타이쿤 문제 풀이는 BOJ 21610 : 마법사 상어와 비바라기와 비슷하지만, 정의된 방향이 다르다./* 0, →, ↗, ↑, ↖, ←, ↙, ↓, ↘ */int dr[] = { 0, 0, -1, -1, -1, 0, 1, 1, 1 };int dc[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 }; 전체 코드는 다음과 같다.#include #define MAX (50 + 5)int T;int N, M;int MAP[MAX][MAX];typedef struct st{ int r; int c;}RC;.. 2024. 6. 9.
[코드트리] 색깔 폭탄 (삼성 SW 역량테스트 2021 상반기 오전 2번) 삼성 A형 전체 링크 Codetree 기출문제 링크 https://www.codetree.ai/training-field/frequent-problems/problems/colored-bomb 색깔 폭탄 문제 풀이는 BOJ 21609 : 상어 중학교와 비슷하지만, 우선순위가 다르다.상어 중학교는 (1) 빨간색 폭탄이 많고, (3) 동일 조건 내 열이 가장 큰 칸을 찾아야 한다. 색깔 폭탄은 빨간색 폭탄이 적어야 하고, 동일 조건 내 열이 가장 작은 칸을 선택하면 된다. 전체 코드는 다음과 같다.#include #define MAX (20 + 5)#define RED (0)#define BLACK (-1)#define EMPTY (-2)int T;int N, M;int MAP[MAX][MAX];/* 순서대.. 2024. 6. 9.
[코드트리] 놀이기구 탑승 (삼성 SW 역량테스트 2021 상반기 오전 1번) 삼성 A형 전체 링크 Codetree 기출문제 링크 https://www.codetree.ai/training-field/frequent-problems/problems/go-on-the-rides 놀이기구 탑승 문제 풀이는 BOJ 21608 : 상어 초등학교와 같다.#include #define MAX (20 + 5)int T;int N;int MAP[MAX][MAX];typedef struct st1{ int index; int love[MAX * MAX];}STUDENT;STUDENT student[MAX * MAX];typedef struct st2{ int r; int c;}RC;RC spot[MAX * MAX];void input(){ scanf("%d", &N); for (int r = 0; r 2024. 6. 9.
[코드트리] 회전하는 빙하 (삼성 SW 역량테스트 2020 하반기 오후 2번) 삼성 A형 전체 링크 Codetree 기출문제 링크 https://www.codetree.ai/training-field/frequent-problems/problems/rotating-glacier 회전하는 빙하 문제 풀이는 BOJ 20058 : 마법사 상어와 파이어스톰과 회전하는 방법이 다르다.여기서는 격자가 전체 회전하지 않고, 부분 격자가 모양을 유지한 채로 회전한다. 따라서 rotate 구현은 아래와 같다. (격자를 나눈 후, 왼쪽 상단 = 1, 오른쪽 상단 = 2, 왼쪽 하단 = 3, 오른쪽 하단 = 4)void rotate(int map[MAX][MAX], int sr, int sc, int size){ int half = size / 2; for (int r = 0; r 1 for (in.. 2024. 6. 9.
[코드트리] 청소는 즐거워 (삼성 SW 역량테스트 2020 하반기 오후 1번) 삼성 A형 전체 링크 Codetree 기출문제 링크 https://www.codetree.ai/training-field/frequent-problems/problems/cleaning-is-joyful 청소는 즐거워 문제 풀이는 BOJ 20057 : 마법사 상어와 토네이도와 같다.#include #define MAX (500 + 20)int T;int N;int MAP[MAX][MAX];void input(){ scanf("%d", &N); for (int r = 0; r N - 1 || nc N - 1) ret += dust; else MAP[nr][nc] += dust; } return ret;}int simulate(){ int outDust, dir, sr, sc, count; sr = s.. 2024. 6. 9.
[코드트리] 원자 충돌 (삼성 SW 역량테스트 2020 하반기 오전 2번) 삼성 A형 전체 링크 Codetree 기출문제 링크 https://www.codetree.ai/training-field/frequent-problems/problems/atom-collision 원자 충돌 문제 풀이는 BOJ 20056 : 마법사 상어와 파이어볼과 같다.#include #define MAX (50 + 5)int T;int N, M, K;typedef struct st1{ int r; int c; int m; int s; int d;}ATOM;ATOM atom[10000 + 5000];int acnt;int dr[] = { -1, -1, 0, 1, 1, 1, 0, -1 };int dc[] = { 0, 1, 1, 1, 0, -1, -1, -1 };typedef struct st2{ int .. 2024. 6. 9.
[코드트리] 불안한 무빙워크 (삼성 SW 역량테스트 2020 하반기 오전 1번) 삼성 A형 전체 링크 Codetree 기출문제 링크 https://www.codetree.ai/training-field/frequent-problems/problems/unstable-moving-walk 불안한 무빙워크 문제 풀이는 BOJ 20055 : 컨베이어 벨트 위의 로봇과 같다.#include #define MAX (100 + 20)int T;int N, K;typedef struct st{ int number; int robotNumber; int A;}MOVING;MOVING moving[MAX * 2];int changeBelt[MAX * 2];int robot[200000 + 5000];int rcnt;void input(){ scanf("%d %d", &N, &K); for (int .. 2024. 6. 9.
[코드트리] 자율주행 전기차 (삼성 SW 역량테스트 2020 상반기 오후 2번) 삼성 A형 전체 링크 Codetree 기출문제 링크 https://www.codetree.ai/training-field/frequent-problems/problems/autonomous-electric-car 자율주행 전기차 문제 풀이는 BOJ 19238 : 스타트 택시와 같다.#include #define MAX (20 + 5)int T;int N, M, F;int MAP[MAX][MAX];typedef struct st1{ int r; int c;}RC;RC car;RC queue[MAX * MAX];int rp, wp;typedef struct st2{ int sr; int sc; int er; int ec; int check;}PEOPLE;PEOPLE people[MAX * MAX];typed.. 2024. 6. 9.
반응형