From e1968e35990bf3b6ce95ea57315fd6f20c2581ef Mon Sep 17 00:00:00 2001 From: sh0723 Date: Mon, 31 Aug 2026 14:18:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?15683=20:=20=EA=B0=90=EC=8B=9C=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week5/BOJ15683/BOj15683_V1.cpp | 102 +++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/week5/BOJ15683/BOj15683_V1.cpp diff --git a/src/week5/BOJ15683/BOj15683_V1.cpp b/src/week5/BOJ15683/BOj15683_V1.cpp new file mode 100644 index 0000000..189c9d8 --- /dev/null +++ b/src/week5/BOJ15683/BOj15683_V1.cpp @@ -0,0 +1,102 @@ +#include +using namespace std; +int N,M; +int room[8][8]; +struct cctv_struct{ + int y, x; + int num; +}; +vector cctv; + +int dy[4] = {-1, 0, 1, 0}; +int dx[4] = {0, 1, 0, -1}; +int directionMask[6] = { + 0, // 0000 + 1, // 0001 + 5, // 0101 + 3, // 0011 + 7, // 0111 + 15 // 1111 +}; + +int cctv_cnt; +int ret = INT_MAX; + +int get_cnt() { + int cnt=0; + for (int i=0; i= N || x < 0 || x >= M) + break; + + if (room[y][x] == 6) + break; + + if (room[y][x] == 0) + room[y][x] = -1; + } +} + +void do_cctv(cctv_struct cctv_arg, int rotation) { + int mask = directionMask[cctv_arg.num]; + + mask = ((mask << rotation) | (mask >> (4 - rotation))) & 0b1111; + + for (int dir = 0; dir < 4; dir++) { + if (mask & (1 << dir)) { + watch(cctv_arg.y, cctv_arg.x, dir); + } + } +} + +void solve(int n) { + if (n == cctv_cnt) { + ret = min(ret, get_cnt()); + return; + } + + for (int i=0; i<4; i++) { + int temp[8][8]; + memcpy(temp, room, sizeof(room)); + do_cctv(cctv[n], i); + solve(n+1); + memcpy(room,temp,sizeof(room)); + } +} + + +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + cin >> N >> M; + + for (int i=0; i> room[i][j]; + if (room[i][j] >=1 && room[i][j] <=5) { + cctv.push_back({i,j,room[i][j]}); + } + } + } + + cctv_cnt = cctv.size(); + + solve(0); + + cout << ret; + + return 0; +} \ No newline at end of file From c6f3a5b8014953d41c50609c06c2c2dec63cea70 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Mon, 31 Aug 2026 14:21:17 +0900 Subject: [PATCH 2/2] =?UTF-8?q?15683=20:=20=EA=B0=90=EC=8B=9C=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EB=AA=85=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week5/BOJ15683/{BOj15683_V1.cpp => BOJ15683_V1.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/week5/BOJ15683/{BOj15683_V1.cpp => BOJ15683_V1.cpp} (100%) diff --git a/src/week5/BOJ15683/BOj15683_V1.cpp b/src/week5/BOJ15683/BOJ15683_V1.cpp similarity index 100% rename from src/week5/BOJ15683/BOj15683_V1.cpp rename to src/week5/BOJ15683/BOJ15683_V1.cpp