본문 바로가기
반응형

알고리즘303

[코드트리] 조삼모사 (삼성 SW 역량테스트 2017 하반기 오전 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/three-at-dawn-and-four-at-dusk 조삼모사 문제 풀이는 BOJ 14889 : 스타트와 링크와 같다.#include #define MAX (20 + 5)int T, N, halfN;int MAP[MAX][MAX];int visit[MAX];int minAnswer;void input(){ scanf("%d", &N); halfN = N / 2; for (int r = 0; r b) ? a - b : b - a;}int minValue(){ int pair[MAX * 2] = { 0 }; int sum1, sum2, scnt, lcnt; scnt .. 2024. 6. 7.
[코드트리] 방화벽 설치하기 (삼성 SW 역량테스트 2017 상반기 오후 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/firewall-installation 방화벽 설치하기 문제 풀이는 BOJ 14502 : 연구소와 같다.#include #define MAX (15)int T;int N, M;int MAP[MAX][MAX];int tmpMAP[MAX][MAX];typedef struct st{ int r; int c;}QUEUE;QUEUE queue[MAX*MAX];int wp, rp;void input(){ scanf("%d %d", &N, &M); for (int r = 0; r rp) { QUEUE out = queue[rp++]; for (int i = 0; i 3) .. 2024. 6. 7.
[코드트리] 자율주행 자동차 (삼성 SW 역량테스트 2017 상반기 오후 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/autonomous-driving 자율주행 자동차 문제 풀이는 BOJ 14503 : 로봇 청소기와 같다.#include #define MAX (50 + 5)int T;int N, M, R, C, D;int MAP[MAX][MAX];int dr[] = { -1, 0, 1, 0 };int dc[] = { 0, 1, 0, -1 };void input(){ scanf("%d %d %d %d %d", &N, &M, &R, &C, &D); for (int r = 0; r 2024. 6. 6.
[코드트리] 외주 수익 최대화하기 (삼성 SW 역량테스트 2017 상반기 오전 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/max-of-outsourcing-profit 외주 수익 최대화하기 문제 풀이는 BOJ 14501 : 퇴사와 같다.#include #define MAX (20+10)int T;int N;int time[MAX];int profit[MAX];int answer;void input(){ scanf("%d", &N); for (int i = 1; i N) { if (start + time[start] == N + 1) sum += profit[start]; if (answer 2024. 6. 6.
[코드트리] 테트리스 블럭 안의 합 최대화 하기 (삼성 SW 역량테스트 2017 상반기 오전 1번 문제) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/max-sum-of-tetris-block 테트리스 블럭 안의 합 최대화 하기 문제 풀이는 BOJ 14500 : 테트로미노와 같다.#include #define MAX (500 +50)int T;int N, M;int MAP[MAX][MAX];int BLOCK[19][4][4] ={ { { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }, { { 1, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, 0, 0, 0 } }, { { 1, 1, 0, 0 .. 2024. 6. 6.
[코드트리] 2048 게임 (삼성 SW 역량테스트 2016 하반기 2번 문제) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/2048-game 2048 게임 문제 풀이는 BOJ 12100 : 2048 Easy와 같다.#include #define MAX (20 + 5)#define LEFT (0)#define UP (1)#define RIGHT (2)#define DOWN (3)int T;int N;int MAP[MAX][MAX];int ANSWER;void(*pMove[5])(int map[][MAX]);void input(){ scanf("%d", &N); for (int r = 0; r = 0; c--) { if (map[r][c] == 0) continue; tmp[r][s.. 2024. 6. 6.
[코드트리] 정육면체 굴리기 (삼성 SW 역량테스트 2016 하반기 1번 문제) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/cube-rounding 정육면체 굴리기 문제 풀이는 BOJ 14499 : 주사위 굴리기와 같다.#include #define MAX (20+5)int T;int N, M, X, Y, K;int MAP[MAX][MAX];int command[1000 + 50];typedef struct st{ int up; int left; int top; int right; int down; int bottom;}CUBE;CUBE cube;int dr[] = { 0, 0, 0, -1, 1 };int dc[] = { 0, 1, -1, 0, 0 };void moveEast(){ int.. 2024. 6. 5.
[코드트리] 2개의 사탕 (삼성 SW 역량테스트 2015 하반기 2번 문제) 삼성 A형 전체 링크  https://www.codetree.ai/training-field/frequent-problems/problems/two-candies 2개의 사탕 문제 풀이는 BOJ 13460 : 구슬 탈출 2와 같다.#include #define MAX (10 + 5)int T;int N, M;char MAP[MAX][MAX];typedef struct st{ int r; int c;}CANDY;CANDY red;CANDY blue;int dr[] = { 0, -1, 0, 1 };int dc[] = { -1, 0, 1, 0 };int minAnswer;void input(void){ minAnswer = 0x7FFF0000; scanf("%d %d", &N, &M); for (int r =.. 2024. 6. 5.
[코드트리] 바이러스 검사 (삼성 SW 역량테스트 2015 하반기 1번 문제) 삼성 A형 전체 링크  https://www.codetree.ai/training-field/frequent-problems/problems/virus-detector 바이러스 검사 문제 풀이는 BOJ 13458 : 시험 감독과 같다.#include #define MAX (1000000 + 50000)typedef long long ll;int T;int N;int restaurant[MAX];int leader, member;void input(){ scanf("%d", &N); for (int i = 0; i 0) sum += (restaurant[i] - 1) / member + 1; } printf("%llu\n", sum); } return 0;} 2024. 6. 3.
반응형