From e12b34e4f1219397b34217b82d4ea32a7cd75093 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Tue, 26 May 2026 02:39:25 +0900 Subject: [PATCH] =?UTF-8?q?1992=20:=20=EC=BF=BC=EB=93=9C=ED=8A=B8=EB=A6=AC?= =?UTF-8?q?=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week2/BOJ1992/BOJ1992_V1.cpp | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/week2/BOJ1992/BOJ1992_V1.cpp diff --git a/src/week2/BOJ1992/BOJ1992_V1.cpp b/src/week2/BOJ1992/BOJ1992_V1.cpp new file mode 100644 index 0000000..ba2e098 --- /dev/null +++ b/src/week2/BOJ1992/BOJ1992_V1.cpp @@ -0,0 +1,56 @@ +#include +using namespace std; +int N; +vector > bitmap; + +int check_same(int y, int x, int size) { + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + if (bitmap[y][x] != bitmap[y+i][x+j]) { + return 0; + } + } + } + return 1; +} + +void solve(int y, int x, int size) { + int half_size = size / 2; + + if (!check_same(y, x, size)) { + cout << "("; + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + solve(half_size*i + y, half_size*j + x, half_size); + } + } + cout << ")"; + return; + } + cout << bitmap[y][x]; + + +} + +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + cin >> N; + + + for (int i = 0; i < N; i++) { + string s; + cin >> s; + bitmap.push_back(vector()); + for (int j = 0; j < N; j++) { + bitmap[i].push_back(s[j] - '0'); + } + } + + solve(0,0,N); + + return 0; +} \ No newline at end of file