본문 바로가기

백준 알고리즘/브루트포스9

백준 1018번 C++ #include #include #include using namespace std; const int MAX = 51;int m, n;string arr[MAX];string whitestart[8] = { { "WBWBWBWB" },{ "BWBWBWBW" },{ "WBWBWBWB" },{ "BWBWBWBW" },{ "WBWBWBWB" },{ "BWBWBWBW" },{ "WBWBWBWB" },{ "BWBWBWBW" }};string blackstart[8] = { { "BWBWBWBW" },{ "WBWBWBWB" },{ "BWBWBWBW" },{ "WBWBWBWB" },{ "BWBWBWBW" },{ "WBWBWBWB" },{ "BWBWBWBW" },{ "WBWBWBWB" } }; int calwhite.. 2019. 2. 4.
백준 14889번 C++ #include#include#includeusing namespace std; const int MAX = 21;int n;int arr[MAX][MAX];int minsum = 987654321; void dfs(string team, int start, int link) {if (start < n/2)dfs(team + "s", start + 1, link);if (link < n/2)dfs(team + "l", start, link + 1);if (team.size() == n) {vector startteam, linkteam;for (int i = 0; i < team.size(); i++) {if (team[i] == 's')startteam.push_back(i);elselinkteam.p.. 2019. 1. 28.
백준 14888번 C++ #include#includeusing namespace std; const int MAX = 1000000001;int n;int number[12];int operators[4];int maxans = -MAX;int minans = MAX; void dfs(int plus, int minus, int mul, int div, int count, int sum) {if (count == n) {maxans = max(maxans, sum);minans = min(minans, sum);}if (plus > 0)dfs(plus - 1, minus, mul, div, count + 1, sum + number[count]);if (minus > 0)dfs(plus, minus - 1, mul, div, .. 2019. 1. 28.
백준 14500번 C++ #include#includeusing namespace std; const int MAX = 501;int n, m;int arr[MAX][MAX];int visited[MAX][MAX]; typedef struct {int a, b;}Move;Move mv[4] = { {1,0},{-1,0},{0,1},{0,-1} }; int dfs(int x, int y,int counts) {if (counts == 4)return 0; int ans = 0;for (int i = 0; i = 0 && mx = 0 && my < m) {if (visited[mx][my] == 0) {v.. 2019. 1. 27.