본문 바로가기
반응형

알고리즘222

[알고리즘] 괄호 추가하기 포인트 연산자 기준으로 재귀가 실행됩니다. 재귀, dfs, 완전탐색, 백트랙킹 은 비슷한 분류 재귀를 생각하는 조건을 조금 더 알아보자 🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다. cpp/c++ #include #include #include using namespace std; int n, operation; int answer = -987654321; int num[21]; char oper[21]; int calc(int a, int b, char input) { if (input == '+') return a + b; if (input == '-') return a - b; if (input == '*') return a * b; } void go(int index, int resul.. 2020. 10. 14.
[알고리즘] 배열 돌리기 4 포인트 정해진 배열을 잘 돌릴 수 있는가? 배열을 밀고 땡긴다라고 생각하면 헷갈릴 수 있다. 값을 복사한다고 생각하면 된다. 그리고 시작지점에 그 다음 번째 값을 복사해주자 🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다. c++/cpp #include #include #define endl "\n" #define MAX 50 + 1 #define K_MAX 6 using namespace std; struct info { int R, C, S; }; int n, m, k, answer; int map[MAX][MAX]; int cmap[MAX][MAX]; bool sel[K_MAX]; vector vc; vector turn; int dx[] = {0, 0, 1, -1}; int dy[] = {.. 2020. 10. 14.
[알고리즘] c++ cpp 구슬탈출 시리즈 (구슬탈출1) 포인트 1. bfs를 잘 할 수 있는가? 2. 조건을 이해할 수 있는가? 🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다. #include #include #include using namespace std; int n, m; char map[11][11]; bool visited[11][11][11][11]; int dx[4] = {0, 0, -1, 1}; int dy[4] = {1, -1, 0, 0}; int rx, ry, bx, by; int bfs() { queue q; q.emplace(rx, ry, bx, by); visited[rx][ry][bx][by] = true; int result = 0; while (!q.empty()) { int size = q.size(); while (.. 2020. 10. 9.
[알고리즘] 구슬 탈출 시리즈 (구슬 탈출 2) 포인트 bfs를 잘 구할 수 있는가? 2개 기준이 있는 맵 방문 표시를 하면서 2가지 구슬의 방문을 저장한다. 🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다. c++/cpp #include #include #include using namespace std; int n, m; char map[11][11]; bool visited[11][11][11][11]; int dx[4] = {0, 0, -1, 1}; int dy[4] = {1, -1, 0, 0}; int rx, ry, bx, by; int bfs() { queue q; q.emplace(rx, ry, bx, by); visited[rx][ry][bx][by] = true; int result = 0; while (!q.empty()) {.. 2020. 10. 9.
반응형