본문 바로가기

전체 글495

[BOJ]14502번: 연구소 (c++) https://www.acmicpc.net/problem/14502 14502번: 연구소 인체에 치명적인 바이러스를 연구하던 연구소에서 바이러스가 유출되었다. 다행히 바이러스는 아직 퍼지지 않았고, 바이러스의 확산을 막기 위해서 연구소에 벽을 세우려고 한다. 연구소는 크� www.acmicpc.net #include #include #include #include using namespace std; template using double_v = vector; struct pos { int x, y; }; int N, M; const int NEW_WALL = 3; enum {LAND, WALL, VIRUS}; int dr_x[] = { 0, 1, 0, -1 }; int dr_y[] = { 1, 0, -.. 2020. 6. 13.
[BOJ]16948번: 데스 나이트 (c++) https://www.acmicpc.net/problem/16948 16948번: 데스 나이트 게임을 좋아하는 큐브러버는 체스에서 사용할 새로운 말 "데스 나이트"를 만들었다. 데스 나이트가 있는 곳이 (r, c)라면, (r-2, c-1), (r-2, c+1), (r, c-2), (r, c+2), (r+2, c-1), (r+2, c+1)로 이동할 수 있다. 크 www.acmicpc.net bfs #include #include #include #include using namespace std; int dr_x[] = {-2, -2, 0, 0, 2, 2}; int dr_y[] = {-1, 1, -2, 2, -1, 1}; struct pos { int x, y; }; int bfs(vector &board.. 2020. 6. 13.
[BOJ]16928번: 뱀과 사다리 게임 (c++) https://www.acmicpc.net/problem/16928 16928번: 뱀과 사다리 게임 첫째 줄에 게임판에 있는 사다리의 수 N(1 ≤ N ≤ 15)과 뱀의 수 M(1 ≤ M ≤ 15)이 주어진다. 둘째 줄부터 N개의 줄에는 사다리의 정보를 의미하는 x, y (x < y)가 주어진다. x번 칸에 도착하면, y번 칸으 www.acmicpc.net bfs #include #include #include #include using namespace std; const int MAX = 100; int bfs(vector &SnL, vector &min_cnt) { // 1부터 시작 queue q; q.push(1); min_cnt[1] = 0; while (!q.empty()) { int now .. 2020. 6. 13.
20200612_TIL 항목 설명 BOJ 알고리즘 문제풀이 구슬 탈출 2 2048 (Easy) 풀이 따흑 2020. 6. 13.