백준

    [실3] 15650 - n과 m(2)

    #include #include using namespace std; #define MAX 9 int n, m; int arr[MAX]{ 0 }; bool visited[MAX]{ 0 }; void dfs(int num, int depth) { if (depth == m) { for (int i = 0; i < m; i++) cout m; dfs(1, 0); }

    [실3] 15649 - n과 m(1)

    #include using namespace std; #define MAX 9 int n, m; int arr[MAX]{ 0 }; bool visited[MAX]{ 0 }; void dfs(int depth) { if (depth == m) { for (int i = 0; i < m; i++) cout m; dfs(0); }

    [골5] 7569 - 토마토

    #include #include #include #include #include #include #include #include using namespace std; using int_pair = pair; #define SIZE 1000 #define y first #define x second // 윗층 뒤 우 아래층 잎 좌 pair arr_pos[] { {1, {0, 0}}, {0, {-1, 0}}, {0, {0, 1}}, {-1, {0, 0}}, {0, {1, 0}}, {0, {0, -1}} }; vector graph; // w:넓이, h:높이, l:층수 int w, h, l; queue q; void BFS() { #define ARR_POS_SIZE 6 while (!q.empty()) { ..

    [골5] 7576 - 토마토

    #include #include #include #include #include #include #include #include using namespace std; using int_pair = pair; #define SIZE 1000 #define y first #define x second // 상 하 좌 우 int_pair arr_pos[] { { 1, 0}, {-1, 0}, {0, -1}, {0, 1} }; vector graph; // w:넓이, h:높이, k:테스트 개수 int w, h, k; queue q; void BFS() { while (!q.empty()) { auto front = q.front(); q.pop(); for (int i = 0; i < 4; i++) { int n..

    [플5] 16496 - 큰 수 만들기

    정렬 함수 3번째 인자 _Pred 람다 함수로 깔끔하게 해결 #include #include #include #include #include using namespace std; #define SIZE 1000 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string arr[SIZE]; int n; cin >> n; cin.ignore(); int flag = 0; for (int i = 0; i > arr[i]; if (arr[i] != "0") flag = true; } if (!flag) cout str2 + str1; }); cout

    [실1] 2583 - 영역 구하기 bfs

    #include #include #include #include #include using namespace std; using int_pair = pair; #define SIZE 1000 #define x first #define y second // 상 하 좌 우 int_pair arr_pos[] { {0, 1}, {0,-1}, {-1,0}, {1, 0} }; queue q; bool graph[SIZE][SIZE]{ false }; int zone = 0; // w:넓이, h:높이, k:테스트 개수 int w, h, k; int BFS() { int block_cnt = 0; while (!q.empty()) { auto front = q.front(); q.pop(); for (int i = 0..

    백준 골5 달성

    흠 지금부터 난이도 급상승

    [실1] 14888 - 연산자 끼워넣기

    #include using namespace std; #define OPERATOR_COUNT 4 int n; int arr_operand[1000]; // 수열 int arr_operator[OPERATOR_COUNT]; int min_val = INT_MAX; int max_val = INT_MIN; void DFS(int result, int idx) { if (idx == n) { if (result > max_val) max_val = result; if (result 0) { arr_operator[i]--; ..

    [실1] 11403 - 경로 찾기

    플로이드 와샬 #include #define INF 100000 #define NODE 1000 using namespace std; int graph[NODE][NODE]{ 0 }; void Floyd_washall() { int n; cin >> n; for (int i = 0; i > graph[i][j]; } for (int k = 0; k < n; k++) // 거쳐가는 노드 { for (int i = 0; i < n; i++) // 출발지 노드 { for (int j = 0; j < n; j++) // 도착지 노드 { if (graph[i][k] && graph[k][j]) graph[i][j]= 1; } } } ..

    [실1] 2667 - 단지 번호 붙이기

    #include #include #include #include #include #include using namespace std; #define TOTAL_SIZE 5000 #define y first #define x second pair dir[] { { 1, 0 }, // 상 {-1, 0 }, // 하 { 0,-1 }, // 좌 { 0, 1} // 우 }; vector res(TOTAL_SIZE); int map[TOTAL_SIZE][TOTAL_SIZE]{ 0 }; bool visited[TOTAL_SIZE][TOTAL_SIZE]; int b_size = 0; int idx = 0; void BFS(int _y, int _x) { // 탐색 시작 queue q; q.push({ _y, _x })..