본문 바로가기
반응형

알고리즘303

[코드트리] 윷놀이 사기단 (삼성 SW 역량테스트 2019 하반기 오후 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/woodstick-fraud 윷놀이 사기단 문제 풀이는 BOJ 17825 : 주사위 윷놀이와 같다.#include int T;int dice[10 + 5];int next[32 + 5][6];int score[32 + 5];int board[32 + 5];int horse[5];int maxAnswer;void input(){ for (int i = 1; i 10) { if (maxAnswer 2024. 6. 8.
[코드트리] 이상한 다트 게임 (삼성 SW 역량테스트 2019 하반기 오후 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/odd-dart-game 이상한 다트 게임 문제 풀이는 BOJ 17822 : 원판 돌리기와 같다.단, 평균에 대한 처리가 다르다. (코드트리는 평균을 구할 때, 소숫점 아래의 수를 버린다.)void averageCircle(){ ... for (int r = 1; r avg) circle[r][c]--; } }} 전체 코드는 다음과 같다.#include #define MAX (50 + 5)int T;int N, M, Q;int circle[MAX][MAX];int X[MAX];int D[MAX];int K[MAX];typedef struct st{ int r; i.. 2024. 6. 8.
[코드트리] 이상한 윷놀이 (삼성 SW 역량테스트 2019 하반기 오전 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/odd-woodstick-game 이상한 윷놀이 문제 풀이는 BOJ 17837 : 새로운 게임 2와 같다.#include #define MAX (12 + 5)#define WHITE (0)#define RED (1)#define BLUE (2)int T;int N, K;int MAP[MAX][MAX];typedef struct st1{ int r; int c; int dir; int index;}HORSE;HORSE horse[12];int hcnt;int deque[MAX][MAX][50];// int front[MAX][MAX];int back[MAX][MAX];.. 2024. 6. 8.
[코드트리] 종전 (삼성 SW 역량테스트 2019 하반기 오전 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/war-finish 종전 문제 풀이는 BOJ 17779 : 게리맨더링 2와 같다.#include #define MAX (20 + 5)int T;int N;int MAP[MAX][MAX];int minAnswer;void input(){ scanf("%d", &N); for (int r = 0; r max) max = sum[i]; } if (max - min 2024. 6. 8.
[코드트리] 바이러스 백신 (삼성 SW 역량테스트 2019 상반기 오후 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/vaccine-for-virus 바이러스 백신 문제 풀이는 BOJ 17142 : 연구소 3과 같다.#include #define MAX (50 + 10)int T;int N, M;int MAP[MAX][MAX];int tmpMAP[MAX][MAX];typedef struct st{ int r; int c;}RC;RC queue[MAX*MAX];int wp, rp;RC virus[MAX*MAX];int vcnt;/* 순서대로 왼쪽, 위, 오른쪽, 아래 */int dr[] = { 0, -1, 0, 1 };int dc[] = { -1, 0, 1, 0 };int minAns.. 2024. 6. 8.
[코드트리] 격자 숫자 놀이 (삼성 SW 역량테스트 2019 상반기 오후 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/matrix-number-play 격자 숫자 놀이 문제 풀이는 BOJ 17140 : 이차원 배열과 연산과 같다.#include #define MAX (100 + 20)int T;int R, C, K;int MAP[MAX][MAX];typedef struct st{ int number; int count;}NC;NC numberCount[MAX];int ncnt = 0;void input(){ scanf("%d %d %d", &R, &C, &K); for (int r = 0; r numberCount[k].count || ((numberCount[i].count.. 2024. 6. 8.
[코드트리] 생명과학부 랩 인턴 (삼성 SW 역량테스트 2019 상반기 오전 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/biology-lab-intern 생명과학부 랩 인턴 문제 풀이는 BOJ 17143 : 낚시왕과 같다.#include #define MAX (100 + 20)int T;int R, C, M;typedef struct st{ int speed; int dir; int size;}MOLD;MOLD mold[MAX][MAX];/* 순서대로 1: 위, 2: 아래, 3: 오른쪽, 4: 왼쪽 */int dr[] = { 0, -1, 1, 0, 0 };int dc[] = { 0, 0, 0, 1, -1 };void input(){ scanf("%d %d %d", &R, &C, &M).. 2024. 6. 8.
[코드트리] 시공의 돌풍 (삼성 SW 역량테스트 2019 상반기 오전 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/heros-of-storm 시공의 돌풍 문제 풀이는 BOJ 17144 : 미세먼지 안녕! 과 같다.#include #define MAX (50 + 10)int T;int R, C, time;int MAP[MAX][MAX];typedef struct st{ int r; int c;}RC;RC tornado[2];int tcnt;void input(){ scanf("%d %d %d", &R, &C, &time); tcnt = 0; for (int r = 1; r 0) { int cnt, dust; cnt = dust = 0; for (int i = .. 2024. 6. 8.
[코드트리] 전투 로봇 (삼성 SW 역량테스트 2018 하반기 오후 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/fighting-robot 전투 로봇 문제 풀이는 BOJ 16236 : 아기 상어와 같다.#include #define MAX (20 + 10)int T;int N;int MAP[MAX][MAX];int visit[MAX][MAX];typedef struct st1{ int r; int c; int eat; int size;}ROBOT;ROBOT attackRobot;typedef struct st2{ int r; int c;}QUEUE;QUEUE queue[MAX * MAX];int wp, rp;int dr[] = { 0, -1, 0, 1 };int dc[] = {.. 2024. 6. 8.
반응형