Algorithm(218)
-
[BOJ] 1759번 : 암호 만들기
1. problem : https://www.acmicpc.net/problem/1759 2. solution 1 :#include using namespace std;int L, C; vector words;vector ans; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> L >> C; for (int i = 0; i > x; words.push_back(x); } sort(words.begin(), words.end()); vector v1(words.size(), 0); fill(v1.end() - L, v1.end(), 1); do { vector temp; int moum_cnt = 0, jaum_cnt = 0; ..
2024.09.16 -
[BOJ] 2667번 : 단지번호붙이기
1. problem : https://www.acmicpc.net/problem/2667 2. solution 1 :#include using namespace std;#define X first#define Y second int board[28][28]; bool isvis[28][28];int dx[4] = { 0,1,0,-1 }; int dy[4] = { 1,0,-1,0 };queue> Q; vector v;int n; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i > x; for (int j = 0; j = n || ny = n) continue; if (board[nx][ny] ..
2024.09.13 -
[BOJ] 2583번 : 영역 구하기
1. problem : https://www.acmicpc.net/problem/2583 2. solution 1 :#include using namespace std;#define X first#define Y secondint m, n, k; int board[105][105];vector v; int cnt;queue> Q; int dx[4] = { 0,1,0,-1 };int dy[4] = { 1,0,-1,0 };int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> m >> n >> k; while (k--) { int a, b, c, d; cin >> a >> b >> c >> d; for (int i = b; i cur = Q.fro..
2024.09.12 -
[BOJ] 15684번 : 사다리 조작
1. problem : https://www.acmicpc.net/problem/15684 2. solution 1 :#include using namespace std;int n, m, h;bool ladders[35][15]; vector> v; // 사다리를 설치할 수 있는 좌표들의 모음집int ans = INT_MAX;bool check() { for (int i = 1; i > n >> m >> h; for (int i = 0; i > a >> b; ladders[a][b] = true; } // 사다리를 설치하는 가능한 경우의 수를 다 저장 for (int i = 1; i backTracking을 이용하여, 풀었다. backTracking을 이용할 때는 parameter에 idx를 두..
2024.09.11 -
[BOJ] 14890번 : 경사로
1. problem : https://www.acmicpc.net/problem/14890 2. solution 1 :#include using namespace std;int n, L; int board[105][105]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> L; for (int i = 0; i > board[i][j]; } int ans = 2 * n; // 행부터 검사 for (int i = 0; i = n) { ans--; break; } bool iswrong = false; for (int k = j; k = n) { ans--; break; } bo..
2024.09.10 -
[BOJ] 1700번 : 멀티탭 스케줄링
1. problem : https://www.acmicpc.net/problem/1700 2. solution 1 :#include using namespace std;int n, k; vector orders; bool powers[105];int ans;int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (int i = 0; i > x; orders.push_back(x); } int cnt = 0; for (int i = 0; i > idx; for (int j = 0; j >()); int target = idx[0].second; powers[target] = false; ans++; po..
2024.09.09