본문 바로가기
반응형

알고리즘303

[코드트리] 바이러스 실험 (삼성 SW 역량테스트 2018 하반기 오후 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/virus-experiment 바이러스 실험 문제 풀이는 BOJ 16235 : 나무 재테크와 같다.#include #define MAX (10 + 5)int T;int N, M, K;int energy[MAX][MAX];int A[MAX][MAX];int virus[MAX][MAX][50000 + 50000];int front[MAX][MAX];int back[MAX][MAX];int dr[] = { -1, -1, -1, 0, 0, 1, 1, 1 };int dc[] = { -1, 0, 1, -1, 1, -1, 0, 1 };void input(){ scanf("%d %.. 2024. 6. 8.
[코드트리] 토스트 계란틀 (삼성 SW 역량테스트 2018 하반기 오전 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/toast-eggmold 토스트 계란틀 문제 풀이는 BOJ 16234 : 인구 이동과 같다.#include #define MAX (100 + 20)#define abs(a) (((a) > 0) ? (a) : -(a))int T;int N, L, R;int A[MAX][MAX];typedef struct st{ int r; int c;}QUEUE;QUEUE queue[MAX * MAX];int wp, rp;void input(){ scanf("%d %d %d", &N, &L, &R); for (int r = 0; r rp) { QUEUE out = queue[rp+.. 2024. 6. 8.
[코드트리] 병원 거리 최소화하기 (삼성 SW 역량테스트 2018 상반기 오후 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/min-of-hospital-distance 병원 거리 최소화하기 문제 풀이는 BOJ 15686 : 치킨 배달과 같다.#include #define MAX (50 + 10)int T;int N, M;int MAP[MAX][MAX];int hospitalList[MAX * 2];typedef struct st{ int r; int c;}RC;RC person[MAX * 2];RC hospital[13 + 5];int pcnt, hcnt;int minAnswer;int abs(int a, int b){ return (a > b) ? a - b : b - a;}int ge.. 2024. 6. 8.
[코드트리] 드래곤 커브 (삼성 SW 역량테스트 2018 상반기 오후 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/dragon-curve 드래곤 커브 문제 풀이는 BOJ 15685 : 드래곤 커브와 같다. (x, y 좌표가 반대)#include #define MAX (100 + 20)int T;int N, y, x, d, g;int MAP[MAX][MAX];int moveList[2000];int dx[] = { 0, -1, 0, 1 };int dy[] = { 1, 0, -1, 0 };void DFS(int L, int length){ if (L > g) return; for (int i = length + 1; i 2024. 6. 7.
[코드트리] 디버깅 (삼성 SW 역량테스트 2018 상반기 오전 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/debugging 디버깅 문제 풀이는 BOJ 15684 : 사다리 조작과 같다.#include int T;int N, M, H;int MAP[30 + 5][10 + 5];int PASS;void input(){ scanf("%d %d %d", &N, &M, &H); for (int r = 0; r 2024. 6. 7.
[코드트리] 이상한 체스 (삼성 SW 역량테스트 2018 상반기 오전 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/odd-chess 이상한 체스 문제 풀이는 BOJ 15683 : 감시와 같다.#include #define MAX (10 + 2)int T;int N, M;int MAP[MAX][MAX];typedef struct st { int r; int c; int number;}CAMERA;CAMERA camera[8 + 2];CAMERA camera5[8 + 2];int cidx;int cidx5;int minAnswer;/* 순서대로 왼쪽, 위, 오른쪽, 아래 */int dr[] = { 0,-1,0,1 };int dc[] = { -1,0,1,0 };void input(){.. 2024. 6. 7.
[코드트리] 연산자 배치하기 (삼성 SW 역량테스트 2017 하반기 오후 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/arrange-operator 연산자 배치하기 문제 풀이는 BOJ 14888 : 연산자 끼워넣기와 같다.#include #define MAX (100 + 20)int T;int N;int numbers[MAX];int possible[5];int minAnswer, maxAnswer;void input(){ scanf("%d", &N); for (int i = 0; i N - 2) { int tmp = calculate(); if (maxAnswer tmp) minAnswer = tmp; } for (int i = 0; i 2024. 6. 7.
[코드트리] 돌아가는 팔각의자 (삼성 SW 역량테스트 2017 하반기 오후 1번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/rounding-eight-angle 돌아가는 팔각의자 문제 풀이는 BOJ 14891 : 톱니바퀴와 같다.#include #define MAX (100 + 20)int T;int wheel[5][10];int N;int number[MAX];int direct[MAX];int list[6];void input(){ for (int number = 1; number = 2; index--) { wheel[number][index] = wheel[number][index - 1]; } wheel[number][1] = temp; }}int check(int co.. 2024. 6. 7.
[코드트리] 보도블럭 (삼성 SW 역량테스트 2017 하반기 오전 2번) 삼성 A형 전체 링크 https://www.codetree.ai/training-field/frequent-problems/problems/crosswalk 보도블럭 문제 풀이는 BOJ 14890 : 경사로와 같다.#include #define MAX (100 + 20)int T;int N, L;int MAP[MAX][MAX];int TMAP[MAX][MAX];void input(){ scanf("%d %d", &N, &L); for (int r = 0; r b) ? a - b : b - a;}int isFlat(int* arr, int start, int end){ int value = arr[start]; for (int i = start + 1; i 1) return 0; /* 2) 높이의 차가.. 2024. 6. 7.
반응형