dp 알파벳 코드 해독

Solution rust soulution Memo 점화식을 알면 쉬운 문제 직전원소와 마지막 원소가 유효한 알파벳이 되면 dp[i] = dp[i-1] + dp[i-2] 아니면 dp[i] = d[i-1] 그리고 점화식도 예시케이스를 모두 작성하면 우연치 않게 보인다. dp문제라는 감만 잡으면 쉽게 풀 수 있다. // Baekjoon - 2011 // https://www.acmicpc.net/problem/2011 use std::io::{self, Read, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input....

May 18, 2025

dp 광고 비용 계산

Solution rust soulution Memo 이건 그냥 개념 // Baekjoon - 1106 // https://www.acmicpc.net/problem/1106 use std::cmp::min; use std::io::{self, Read, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input.lines(); let mut costs: Vec<(usize, usize)> = vec![]; let first_line: Vec<usize> = lines .next() .unwrap() .split_whitespace() .map(|x| x.parse().unwrap()) .collect(); let target = first_line[0]; let n = first_line[1]; for _ in 0....

May 17, 2025

dp 스케줄 문제

Solution rust soulution Memo 이건 그냥 개념 use std::cmp::max; use std::io::{self, Read, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input.lines(); let n: usize = lines.next().unwrap().parse().unwrap(); let mut schedule: Vec<usize> = vec![0; n]; let mut payments: Vec<usize> = vec![0; n]; for i in 0..n { let tmp_line: Vec<usize> = lines .next() .unwrap() .split_whitespace() ....

May 17, 2025

dp 동전 문제

Solution rust soulution Memo 이건 그냥 개념 // Baekjoon - 2293 // https://www.acmicpc.net/problem/2293 use std::io::{self, Read, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input.lines(); let first_line: Vec<usize> = lines .next() .unwrap() .split_whitespace() .map(|x| x.parse().unwrap()) .collect(); let n = first_line[0]; let k = first_line[1]; let mut coins: Vec<usize> = vec![]; for _ in 0....

May 17, 2025

구현이 귀찮은 dfs 문제

Solution rust soulution Memo 이건 그냥 개념 // Baekjoon - 2468 // https://www.acmicpc.net/problem/2468 use std::cmp::max; use std::io::{self, Read, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input.lines(); let n: usize = lines.next().unwrap().parse().unwrap(); let mut water_max: usize = 0; let mut graph: Vec<Vec<usize>> = vec![]; for i in 0..n { let tmp: Vec<usize> = lines ....

May 16, 2025

bfs 최단거리

Solution rust soulution Memo 이건 그냥 개념 최단거리 = bfs // Baekjoon - 1697 // https://www.acmicpc.net/problem/1697 use std::collections::VecDeque; use std::io::{self, Read, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input.lines(); // let n: usize = lines.next().unwrap().parse().unwrap(); let first_line: Vec<usize> = lines .next() .unwrap() .split_whitespace() .map(|x| x.parse().unwrap()) .collect(); let n = first_line[0]; let k = first_line[1]; let output = bfs(n, k); write!...

May 16, 2025

dfs 기본문제

Solution rust soulution Memo 이건 그냥 개념 // Baekjoon - 2606 // https://www.acmicpc.net/problem/2606 use std::io::{self, Read, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input.lines(); let n: usize = lines.next().unwrap().parse().unwrap(); let m: usize = lines.next().unwrap().parse().unwrap(); let mut graph: Vec<Vec<usize>> = vec![vec![]; n + 1]; for _ in 0..m { let tmp: Vec<usize> = lines....

May 15, 2025

bfs 기본문제

Solution rust soulution Memo 이건 그냥 개념 // Baekjoon - 2178 // https://www.acmicpc.net/problem/2178 use std::collections::VecDeque; use std::io::{self, Read, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input.lines(); let first_line: Vec<usize> = lines .next() .unwrap() .split_whitespace() .map(|x| x.parse().unwrap()) .collect(); let y = first_line[0]; let x = first_line[1]; let mut map: Vec<Vec<usize>> = vec![]; for _ in 0....

May 15, 2025

dfs, bfs 개념 문제

Solution rust soulution Memo 이건 그냥 개념 // Baekjoon - 1260 // https://www.acmicpc.net/problem/1260 use std::collections::VecDeque; use std::io::{self, Read, StdoutLock, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input.lines(); let first_line: Vec<usize> = lines .next() .unwrap() .split_whitespace() .map(|x| x.parse().unwrap()) .collect(); let n = first_line[0]; let m = first_line[1]; let v = first_line[2]; let mut graph: Vec<Vec<usize>> = vec!...

May 14, 2025

투포인터 부분수열

Solution rust soulution Memo 부분수열로 특정 값 이상을 달성하게 만들어 각 부분수열의 크기의 최소값을 구하는 문제 left, right 를 0에서 시작하고, right를 전진시키고, 특정값 이상이 된다면 left를 땡겨와서 // Baekjoon - 1806 // https://www.acmicpc.net/problem/1806 use std::cmp::min; use std::io::{self, Read, Write}; fn main() { let mut stdin = io::stdin().lock(); let mut stdout = io::stdout().lock(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let mut lines = input.lines(); let meta_line: Vec<usize> = lines ....

May 13, 2025