-
Rust lang) 백준 5397 키로거Rust 2024. 1. 9. 07:29
// 백준 5397 키로거 rust // https://www.acmicpc.net/problem/5397 use std::io::{stdin, BufRead}; fn main() { let std= stdin(); let mut buf= std.lock().lines(); let input= buf.next().unwrap().unwrap(); let t: i32= input.trim().parse().unwrap(); let mut inputes: Vec<char>; for _ in 0..t{ let mut left: Vec<char> = Vec::new(); let mut right: Vec<char> = Vec::new(); let input2= buf.next().unwrap().unwrap(); inputes= input2.trim().chars().collect(); for c in inputes{ match c { '<' => { if !left.is_empty(){ right.push(left.pop().unwrap()); } }, '>' => { if !right.is_empty() { left.push(right.pop().unwrap()); } }, '-' => { if !left.is_empty() { left.pop(); } }, _ => left.push(c), } } while !left.is_empty() { right.push(left.pop().unwrap()); } // let results: Vec<String>= Vec::new(); let mut answer= String::new(); while !right.is_empty() { answer.push(right.pop().unwrap()); } println!("{}", answer); answer= String::new(); // 2 // <<BP<A>>Cd- // ThIsIsS3Cr3t } }
'Rust' 카테고리의 다른 글
Rust lang) 백준 7562번 : 나이트의 이동 (0) 2024.01.16 Rust lang) leetcode 207. Course Schedule (0) 2024.01.11 Rust lang) 백준 15903 카드 합체 놀이 (1) 2024.01.09 Rust Lang) 백준 2002 추월 (0) 2024.01.09 rust lang) 백준 1927 최소 힙 (1) 2024.01.09