Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- ue5
- 재귀
- c++
- 그리디 알고리즘
- DFS
- 백준
- Team Fortress 2
- 누적 합
- BFS
- VR
- 우선순위 큐
- 정렬
- 그래프
- 구현
- 투 포인터
- 백트래킹
- 다익스트라
- Unreal Engine 5
- 알고리즘
- 브루트포스
- 다이나믹 프로그래밍
- 문자열
- XR Interaction Toolkit
- 유니티
- 시뮬레이션
- 트리
- 자료구조
- 유니온 파인드
- 스택
- 수학
Archives
- Today
- Total
1일1알
백준 17829번 222-풀링 C++ 본문
https://www.acmicpc.net/problem/17829
17829번: 222-풀링
조기 졸업을 꿈꾸는 종욱이는 요즘 핫한 딥러닝을 공부하던 중, 이미지 처리에 흔히 쓰이는 합성곱 신경망(Convolutional Neural Network, CNN)의 풀링 연산에 영감을 받아 자신만의 풀링을 만들고 이를 22
www.acmicpc.net
재귀
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int n;
vector<vector<int>> board;
int rec(int row, int col, int len) {
if (len == 1) {
return board[row][col];
}
vector<int> tmp;
tmp.push_back(rec(row, col, len / 2));
tmp.push_back(rec(row, col + len / 2, len / 2));
tmp.push_back(rec(row + len / 2, col, len / 2));
tmp.push_back(rec(row + len / 2, col + len / 2, len / 2));
sort(tmp.begin(), tmp.end());
return tmp[2];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
board = vector<vector<int>>(n, vector<int>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> board[i][j];
}
}
int ans = rec(0, 0, n);
cout << ans;
}
'알고리즘' 카테고리의 다른 글
백준 17828번 문자열 화폐 C++ (0) | 2023.05.07 |
---|---|
백준 2615번 오목 C++ (0) | 2023.05.06 |
백준 2508번 사탕 박사 고창영 C++ (0) | 2023.05.04 |
백준 3060번 욕심쟁이 돼지 C++ (0) | 2023.05.03 |
백준 2799번 블라인드 C++ (0) | 2023.05.02 |