일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- msSQL
- 오퍼레터
- upper_bound
- OFFSET
- Docker
- 물채우기
- 매개변수탐색
- 기술면접
- 연결요소
- 처우산정
- 파라메트릭
- compose
- @P0
- boj #19237 #어른 상어
- 퇴사통보
- Kafka
- incr
- BFS
- 경력
- 6987
- 이분탐색
- 소프티어
- dfs
- 처우협의
- 백트래킹
- BOJ
- 성적평가
- 13908
- softeer
- 백준
- Today
- Total
목록알고리즘 문제/BOJ (413)
기술 블로그
https://www.acmicpc.net/problem/2810 핵심은 제일 끝 쪽(오른 쪽 끝)에 있는 사람은 오른쪽부터 먹는다. 그 이후이 사람은 왼쪽을 먹는다. "S"와 "LL" 파싱 없이 할 수 있을 것 같은데 그냥 파싱해봄 #include using namespace std; int n; string s; int main() { //freopen("C:\\Users\\park7\\Desktop\\lazy_bronze\\2.in", "r", stdin); cin.tie(0); cin >> n >> s; int len = s.length(); string ps = ""; vector v; // "S"와 "LL"을 파싱하여 vector v에 담음. for (int i = len - 1; i >= 0..
https://www.acmicpc.net/problem/1525 문자열 처리 + bfs 방문처리는 문자열로 처리해준다. 문자열에 대한 방문처리는 set이 좋다. #include using namespace std; string s = "", goal = "123456780"; int dy[4] = { 1, 0, -1, 0 }; int dx[4] = { 0, 1, 0, -1 }; set st; int bfs() { queue q; q.push(s); st.insert(s); int ret = 0; while (!q.empty()) { int qs = q.size(); while (qs--) { string now = q.front(); q.pop(); if (now == goal) { return ret..
https://www.acmicpc.net/problem/2571 문제 풀이 1. 높이 누적합 2. 한 좌표(r, c)에 대해서 모든 경우의 수에 따른 사각형 넓이 구하기(simulation, getValue 함수) 3. 높이(세로)와 가로 길이 구할 때 조심. 높이는 항상 최솟값. 높이 : 그 열의 맨 아래에 있는 좌표값 + 1 - 자신의 현재 좌표 값 가로 : (r, c) ~ (r, j)에 해당 하는 단순 가로의 길이이므로, j - c + 1 #include using namespace std; #define MAX 101 int n, ans, p[MAX][MAX]; void draw(int r, int c) { for (int i = r; i < r + 10; i++) { for (int j = c..
https://www.acmicpc.net/problem/1953 이분 그래프 문제이다. 참고 문제 : https://www.acmicpc.net/problem/1707 참고 풀이 : https://hsdevelopment.tistory.com/74 #include using namespace std; #define MAX 101 int N, M, T; vector v[MAX]; vector a, b; int color[MAX]; bool go(int now, int next) { for (auto i : v[now]) { if (i == next) { return false; } } return true; } void dfs(int vertex, int nodeColor) { color[vertex] ..
https://www.acmicpc.net/problem/17836 1. 방문 처리할 때, 그람을 먹었는지와 아직 먹지 않았는지 2가지를 따져야한다. 즉, 3차원 방문 처리 2. 제한시간인 T시간을 고려하여 구현한다. 그냥 현재 그 순간의 시간(d)을 활용하여 T와 비교하면 된다. 도착했을 때, 이제 먹으려고 할 때 d vs T #include using namespace std; #define MAX 101 typedef struct{ int r, c, g, d; }info; int N, M, T; int m[MAX][MAX]; int dy[4] = { 0, 1, 0, -1 }; int dx[4] = { 1, 0, -1, 0 }; bool used[MAX][MAX][2]; // 0 : 그람을 먹지 않았..
https://www.acmicpc.net/problem/16493 냅색 #include using namespace std; int N, M, cache[201][21]; vector v; int ks(int goal, int idx) { if (idx == M) { return 0; } int& ret = cache[goal][idx]; if (ret != -1) return ret; ret = ks(goal, idx + 1); if (goal - v[idx].first >= 0) { ret = max(ret, ks(goal - v[idx].first, idx + 1) + v[idx].second); } return ret; } int main() { //freopen("C:\\Users\\park7..
https://www.acmicpc.net/problem/3067 냅색 #include using namespace std; int N, T, cache[10001][21]; vector v; int ks(int goal, int idx) { if (idx == N) { if (goal == 0) return 1; return 0; } int& ret = cache[goal][idx]; if (ret != -1) return ret; ret = ks(goal, idx + 1); if (goal - v[idx] >= 0) { ret += max(ks(goal - v[idx], idx), ks(goal - v[idx], idx + 1)); } return ret; } int main() { //freopen..
https://www.acmicpc.net/problem/14728 냅색 문제이다. #include using namespace std; int N, T, cache[10001][101]; vector v; int ks(int T, int idx) { if (idx == N) { return 0; } int& ret = cache[T][idx]; if (ret != -1) return ret; ret = 0; // 우선 현재 순서를 건너 뛰어본다. ret = max(ret, ks(T, idx + 1)); // 알맞은 조건 하에 현재 순서를 진행한다. if (T - v[idx].first >= 0) { // 비교 ret = max(ret, ks(T - v[idx].first, idx + 1) + v[idx..