본문 바로가기

BOJ206

[BOJ]17085번: 십자가 2개 놓기(c++) www.acmicpc.net/problem/17085 17085번: 십자가 2개 놓기 첫째 줄에 격자판의 크기 N, M (2 ≤ N, M ≤ 15)이 주어진다. 둘째 줄부터 N개의 줄에 격자판의 상태가 주어진다. 항상 두 개의 십자가를 놓을 수 있는 경우만 입력으로 주어진다. www.acmicpc.net 브루트 포스 #include #include #include using namespace std; template using d_vector = vector; struct pos { int y, x; }; // right, down, left, up int dr_y[] = {0, 1, 0, -1}; int dr_x[] = {1, 0, -1, 0}; int N, M; vector board; // 십자가(.. 2020. 9. 15.
[BOJ]1786번: 찾기 (c++) www.acmicpc.net/problem/1786 1786번: 찾기 첫째 줄에, T 중간에 P가 몇 번 나타나는지를 나타내는 음이 아닌 정수를 출력한다. 둘째 줄에는 P가 나타나는 위치를 차례대로 출력한다. 예컨대, T의 i~i+m-1번 문자와 P의 1~m번 문자가 차례로 � www.acmicpc.net KMP 문자열 알고리즘 #include #include using namespace std; // Prefix Index 배열 만들기 vector make_pi(string &pattern) { int len = pattern.size(); vector pi(len); for (int i = 1, j = 0; i 0 && pattern[i] != patter.. 2020. 9. 12.
[BOJ]2234번: 성곽 (c++) www.acmicpc.net/problem/2234 2234번: 성곽 첫째 줄에 두 정수 n, m이 주어진다. 다음 m개의 줄에는 n개의 정수로 벽에 대한 정보가 주어진다. 벽에 대한 정보는 한 정수로 주어지는데, 서쪽에 벽이 있을 때는 1을, 북쪽에 벽이 있을 때는 2를, www.acmicpc.net BFS #include #include #include #include using namespace std; template using d_vector = vector; int dr_y[] = {0, -1, 0, 1}; int dr_x[] = {-1, 0, 1, 0}; int N, M; d_vector castle; d_vector labeled_castle; // 방 번호(1부터 시작)를 라벨링할 2차원.. 2020. 9. 12.
[BOJ]11060번: 점프 점프 (c++) www.acmicpc.net/problem/11060 11060번: 점프 점프 재환이가 1×N 크기의 미로에 갇혀있다. 미로는 1×1 크기의 칸으로 이루어져 있고, 각 칸에는 정수가 하나 쓰여 있다. i번째 칸에 쓰여 있는 수를 Ai라고 했을 때, 재환이는 Ai이하만큼 오른쪽으로 � www.acmicpc.net DP #include #include using namespace std; int N; const int MAX = 1000; void get_min_jump_cnt(vector &maze, vector &DP, int strt) { for (int i = maze[strt]; i > 0; --i) { int next = strt + i; if (next DP[st.. 2020. 9. 11.