rust37 [백준] 1028번 : 다이아몬드 광산 https://www.acmicpc.net/problem/1028use io::Write;use std::{io, str};pub struct UnsafeScanner { reader: R, buf_str: Vec, buf_iter: str::SplitAsciiWhitespace,}impl UnsafeScanner { pub fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_ascii_whitespace(), } } pub fn token(&mut self) -> T { loop { .. 2025. 11. 29. [백준] 17420번 : 깊콘이 넘쳐흘러 https://www.acmicpc.net/problem/17420use io::Write;use std::{io, str};pub struct UnsafeScanner { reader: R, buf_str: Vec, buf_iter: str::SplitAsciiWhitespace,}impl UnsafeScanner { pub fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_ascii_whitespace(), } } pub fn token(&mut self) -> T { loop { if let Some(token) = self.buf_iter.nex.. 2025. 11. 23. [백준] 11920번 : 버블 정렬 https://www.acmicpc.net/problem/11920해당 문제는 n개의 수를 입력받으면서 k번째 수부터 우선순위큐에서 제거하여 출력하는 방식으로 해결할 수 있습니다.Rust에서의 heap은 최대힙이므로 Reverse()를 활용하여 최소힙으로 구성하여 해결하면 됩니다.use io::Write;use std::{io, str};use std::cmp::Reverse;use std::collections::BinaryHeap;pub struct UnsafeScanner { reader: R, buf_str: Vec, buf_iter: str::SplitAsciiWhitespace,}impl UnsafeScanner { pub fn new(reader: R) -> Self { Self.. 2025. 11. 13. [백준] 2220번 : 힙 정렬 https://www.acmicpc.net/problem/2220이 문제는 그리디하게 swap을 이용하여 해결하면 됩니다.use io::Write;use std::{io, str};pub struct UnsafeScanner { reader: R, buf_str: Vec, buf_iter: str::SplitAsciiWhitespace,}impl UnsafeScanner { pub fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_ascii_whitespace(), } } pub fn token(&mut self) -> T { loop { if let .. 2025. 11. 9. 이전 1 2 3 4 ··· 10 다음