Algorithm(218)
-
[BOJ] 2240번 : 자두나무
1. problem : https://www.acmicpc.net/problem/2240 2. solution 1 :#include using namespace std;int t, w; int d[1005][32][3]; int cherry[1005];int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> t >> w; for (int i = 1; i > cherry[i]; for (int i = 1; i source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/workbook/0x10.md basic-algo-lecture/workbook/0x10.md at..
2024.09.20 -
[BOJ] 13913번 : 숨바꼭질 4
1. problem : https://www.acmicpc.net/problem/13913 2. solution 1 :#include using namespace std;#define X first #define Y second int n, k;pair axis[200005]; int dx[2] = { 1,-1 };queue Q;int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; fill(axis, axis + 200005, make_pair(-1, -1)); axis[n] = { 0,n }; // cnt 와 전 index값 입력 Q.push(n); bool isfind = false; while (!Q.empty()) { ..
2024.09.19 -
[BOJ] 6593번 : 상범 빌딩
1. problem : https://www.acmicpc.net/problem/6593 2. solution 1 :#include using namespace std;char board[32][32][32]; int dx[6] = { 0,1,0,-1,0,0 }; int dy[6] = { 1,0,-1,0,0,0 }; int dz[6] = { 0,0,0,0,1,-1 };queue> Q;int main(void) { ios::sync_with_stdio(0); cin.tie(0); while (true) { int L, R, C; cin >> L >> R >> C; int isvis[32][32][32] = {}; while (!Q.empty()) Q.pop(); if (L == 0 && R ..
2024.09.19 -
[BOJ] 2468번 : 안전 영역
1. problem : https://www.acmicpc.net/problem/2468 2. solution 1 :#include using namespace std;#define X first #define Y secondint n; int board[105][105]; int dx[4] = { 0,1,0,-1 };int dy[4] = { 1,0,-1,0 };queue> Q;int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; int mx_ht = 0, mn_ht = INT_MAX; for (int i = 0; i > board[i][j]; mx_ht = max(mx_ht, board[i][j]); mn_ht = min(mn_ht,..
2024.09.18 -
[BOJ] 5014번 : 스타트링크
1. problem : https://www.acmicpc.net/problem/5014 2. solution 1: #include using namespace std;int f, s, g, u, d; typedef long long ll;long long elev[1000005]; // 몇번째에 도착했는지 기록 ; queue Q; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> f >> s >> g >> u >> d; elev[s] = 1; Q.push(s); int dx[2] = { u,-d }; while (!Q.empty()) { int cur = Q.front(); Q.pop(); for (int dir = 0; dir ..
2024.09.18 -
[BOJ] 2748번 : 피보나치 수 2
1. problem : https://www.acmicpc.net/problem/2748 2. solution 1 :#include using namespace std;int n;long long dp[100]; long long dynamic_func(int k) { if (k == 0 || k == 1) { return k; } if (dp[k]) return dp[k]; return dp[k] = dynamic_func(k-1) + dynamic_func(k-2);}int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; long long ans = dynamic_func(n); cout dp를 이용하여, 해결하였다. 단순 재귀를 이..
2024.09.18