結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
|
提出日時 | 2024-10-12 15:47:00 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 1,728 bytes |
コンパイル時間 | 13,171 ms |
コンパイル使用メモリ | 379,520 KB |
実行使用メモリ | 8,448 KB |
最終ジャッジ日時 | 2024-10-16 17:55:08 |
合計ジャッジ時間 | 14,180 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#![allow(non_snake_case)] #![allow(unused_imports)] #![allow(unused_macros)] #![allow(clippy::needless_range_loop)] #![allow(clippy::comparison_chain)] #![allow(clippy::nonminimal_bool)] #![allow(clippy::neg_multiply)] #![allow(dead_code)] #![allow(clippy::collapsible_else_if)] use proconio::{ fastout, input, input_interactive, marker::{Chars, Usize1}, }; use std::cmp::Reverse; use std::collections::BinaryHeap; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque}; use std::mem::swap; //const MOD: usize = 1e9 as usize + 7; const MOD: usize = 998244353; // const MOD: usize = 2147483647; #[macro_export] macro_rules! max { ($x: expr) => ($x); ($x: expr, $( $y: expr ),+) => { std::cmp::max($x, max!($( $y ),+)) } } #[macro_export] macro_rules! min { ($x: expr) => ($x); ($x: expr, $( $y: expr ),+) => { std::cmp::min($x, min!($( $y ),+)) } } fn main() { input! { S:Chars, } let mut stk = VecDeque::new(); let N = S.len(); for i in 0..N { if S[i] == '>' { let mut tmp_stk = VecDeque::new(); tmp_stk.push_back(S[i]); while !stk.is_empty() && stk[stk.len() - 1] == '=' { tmp_stk.push_back(stk.pop_back().unwrap()); } if !stk.is_empty() && stk[stk.len() - 1] == '<' && tmp_stk.len() >= 2 { tmp_stk.push_back(stk.pop_back().unwrap()); } else { while !tmp_stk.is_empty() { stk.push_back(tmp_stk.pop_back().unwrap()); } } //eprintln!("{:?}", stk); } else { stk.push_back(S[i]); } } println!("{}", stk.len()); }