전체 글(331)
-
[BOJ] 11559번 : Puyo Puyo
1. problem : https://www.acmicpc.net/problem/11559 2. solution 1 :// source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x0D/solutions/11559.cpp#include using namespace std; bool ispuyo; bool vis[12][6];string board[12]; int dx[4] = { 1,0,-1,0 };int dy[4] = { 0,1,0,-1 }; int ans;void resetvis() { for (int i = 0; i > trash; queue> Q; vis[x][y] = true; char color =..
2024.08.21 -
[BOJ] 15686번 : 치킨 배달
1. problem : https://www.acmicpc.net/problem/15686 2. solution 1 :#include using namespace std;#define X first#define Y second int n, m;int board[52][52]; vector> house;vector> all_chicken;vector> cho_chicken;bool isUsed[15];int mn_dist = 15000; void chickenDist(int cnt, int target_cnt) { if (target_cnt == cnt) { int dist_sum = 0; for (int i = 0; i > n >> m; for (int i = 0; i > board[i][j]; ..
2024.08.20 -
[BOJ] 12100번 : 2048 (Easy)
1. problem :https://www.acmicpc.net/problem/12100 2. solution : // Authored by : BaaaaaaaaaaarkingDog// Co-authored by : -// http://boj.kr/82284615e5814db489ee482ef77bcaf4#include using namespace std;int board1[21][21];int board2[21][21];int n;void rotate(){ // board2를 시계 방향으로 90도 회전하는 함수 int tmp[21][21]; for(int i = 0; i > n; for(int i = 0; i > board1[i][j]; int mx = 0; for(int tmp = 0; tm..
2024.08.20 -
[BOJ] 18808번 : 스티커 붙이기
1. problem : https://www.acmicpc.net/problem/18808 2. solution 1 :// source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x0D/solutions/18808.cpp#include using namespace std;int n, m, k; // 노트북 행, 열 스티커 개수 int r, c; // 스티커 row, col ; int paper[12][12];int note[42][42]; bool pastable(int x, int y) { for (int i = 0; i > n >> m >> k; while (k--) { cin >> r >> c; for ..
2024.08.20 -
[C++] 변수가 서로 독립적일때, backTracking의 대안
1. 서론 BOJ 15683번 감시문제를 풀다 보면, cctv의 종류에 따라, 행동양식이 틀려진다. 이때, 경우의 수를 따져 야하기 때문에 backtracking을 이용할 수 있지만, 이때 유용한 방법을 알아서 적는다. 2. 본론경우의수cctv1(4제곱승)cctv2(4의1승)cctv3(4의0승)000010012002... ... ... 6233263333만약에 이 문제에서 cctv가 4가지의 경우의 수가 있다고 가정하자. 그렇다면, cctv의 개수가 3개라면 , 총 64가지의 경우의 수가 나온다. 이럴 때는 4진수로 표현을 한다. 1 이것을 표로 표현하자면 위와 같다. 이때, int dx [4] = {1,0,-1,0} , int dy [4] = {0,1,0,-1}로 두어, 방향성을 계산할 수..
2024.08.19 -
[BOJ] 15683번 : 감시
1. problem : https://www.acmicpc.net/problem/15683 2. solution 1 :#include using namespace std;int office[8][8];int minZero = 1000;int N, M; // row , col; vector> v_cctv; // cctv 위치와 종류저장void xplus_count(int x, int y) { while (y 0 && idx_val 0) { y--; int idx_val = office[x][y]; //x축 음의방향으로 옮겼을 때 들어있는 값; if (idx_val == 0) office[x][y] = -1; else if (idx_val == 6) return; else if (idx_val ..
2024.08.19