From 262ffe9a3b612633ead828dcb5316a6402e7d08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=9C=A4=ED=95=98?= Date: Sun, 6 Mar 2022 00:48:28 +0900 Subject: [PATCH] =?UTF-8?q?B0J=5F1922=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Algorithm.sln | 10 ++ ...3\223\234\355\212\270\353\246\254.vcxproj" | 150 ++++++++++++++++++ ...4\355\212\270\353\246\254.vcxproj.filters" | 27 ++++ .../input.txt" | 9 ++ .../main.c" | 68 ++++++++ 5 files changed, 264 insertions(+) create mode 100644 "DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254.vcxproj" create mode 100644 "DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254.vcxproj.filters" create mode 100644 "DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/input.txt" create mode 100644 "DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/main.c" diff --git a/Algorithm.sln b/Algorithm.sln index cba5c0c..c91deb9 100644 --- a/Algorithm.sln +++ b/Algorithm.sln @@ -7,6 +7,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DC_1_Tromino", "DC_1_Tromin EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DC_2_종이의 개수", "DC_2_종이의 개수\DC_2_종이의 개수.vcxproj", "{678EB73C-A420-47B1-AF1F-AB5CE7B682D6}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DC_3_쿼드트리", "DC_3_쿼드트리\DC_3_쿼드트리.vcxproj", "{B2A211F5-BEAC-4355-9208-89ADD8A34507}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -31,6 +33,14 @@ Global {678EB73C-A420-47B1-AF1F-AB5CE7B682D6}.Release|x64.Build.0 = Release|x64 {678EB73C-A420-47B1-AF1F-AB5CE7B682D6}.Release|x86.ActiveCfg = Release|Win32 {678EB73C-A420-47B1-AF1F-AB5CE7B682D6}.Release|x86.Build.0 = Release|Win32 + {B2A211F5-BEAC-4355-9208-89ADD8A34507}.Debug|x64.ActiveCfg = Debug|x64 + {B2A211F5-BEAC-4355-9208-89ADD8A34507}.Debug|x64.Build.0 = Debug|x64 + {B2A211F5-BEAC-4355-9208-89ADD8A34507}.Debug|x86.ActiveCfg = Debug|Win32 + {B2A211F5-BEAC-4355-9208-89ADD8A34507}.Debug|x86.Build.0 = Debug|Win32 + {B2A211F5-BEAC-4355-9208-89ADD8A34507}.Release|x64.ActiveCfg = Release|x64 + {B2A211F5-BEAC-4355-9208-89ADD8A34507}.Release|x64.Build.0 = Release|x64 + {B2A211F5-BEAC-4355-9208-89ADD8A34507}.Release|x86.ActiveCfg = Release|Win32 + {B2A211F5-BEAC-4355-9208-89ADD8A34507}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git "a/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254.vcxproj" "b/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254.vcxproj" new file mode 100644 index 0000000..ef8b0ae --- /dev/null +++ "b/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254.vcxproj" @@ -0,0 +1,150 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {b2a211f5-beac-4355-9208-89add8a34507} + DC3쿼드트리 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git "a/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254.vcxproj.filters" "b/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254.vcxproj.filters" new file mode 100644 index 0000000..29015cd --- /dev/null +++ "b/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254.vcxproj.filters" @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 소스 파일 + + + + + 리소스 파일 + + + \ No newline at end of file diff --git "a/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/input.txt" "b/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/input.txt" new file mode 100644 index 0000000..daa7811 --- /dev/null +++ "b/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/input.txt" @@ -0,0 +1,9 @@ +8 +11110000 +11110000 +00011100 +00011100 +11110000 +11110000 +11110011 +11110011 \ No newline at end of file diff --git "a/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/main.c" "b/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/main.c" new file mode 100644 index 0000000..9fde9f2 --- /dev/null +++ "b/DC_3_\354\277\274\353\223\234\355\212\270\353\246\254/main.c" @@ -0,0 +1,68 @@ +// BOJ_1992 + +#define _CRT_SECURE_NO_WARNINGS +#define TRUE 1 +#define FALSE 0 + +#include +#include + +int check(int n, int start_i, int start_j); +void divideMat(int n, int start_i, int start_j); + +int** mat; + +int main() { + /*FILE* fp; + if ((fp = fopen("input.txt", "r")) == NULL) { + fprintf("file open error!\n", stderr); + exit(1); + }*/ + + int n; + + fscanf(stdin, "%d", &n); + + mat = (int**)malloc(sizeof(int*) * n); + for (int i = 0;i < n;i++) { + mat[i] = (int*)malloc(sizeof(int) * n); + } + + for (int i = 0;i < n;i++) { + for (int j = 0;j < n;j++) { + fscanf(stdin, "%1d", &mat[i][j]); // get one digit + } + } + + divideMat(n, 0, 0); + + return 0; +} + +int check(int n, int start_i, int start_j) { + int pivot = mat[start_i][start_j]; + + for (int i = start_i;i < start_i + n;i++) { + for (int j = start_j;j < start_j + n;j++) { + if (mat[i][j] != pivot) + return FALSE; + } + } + printf("%d", pivot); + return TRUE; +} + +void divideMat(int n, int start_i, int start_j) { + int res = check(n, start_i, start_j); + int next_size = n / 2; + + if (res == FALSE && n >= 2) { // exit condition + printf("("); + for (int i = start_i;i < start_i + n;i += next_size) { + for (int j = start_j;j < start_j + n;j += next_size) { + divideMat(next_size, i, j); + } + } + printf(")"); + } +} \ No newline at end of file