結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
![]() |
提出日時 | 2024-06-16 08:25:29 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 820 bytes |
コンパイル時間 | 14,812 ms |
コンパイル使用メモリ | 378,536 KB |
実行使用メモリ | 6,400 KB |
最終ジャッジ日時 | 2024-10-16 17:53:00 |
合計ジャッジ時間 | 15,377 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
use proconio::input; use proconio::fastout; use proconio::marker::Chars; #[fastout] #[allow(non_snake_case)] fn main() { input! { S: Chars, } let N = S.len(); let mut stk = Vec::new(); let mut cnt = 0; for i in 0..N { if S[i] == '<' { stk.push(S[i]); cnt += 1; } else if S[i] == '=' { stk.push(S[i]); } else { let len = stk.len(); if cnt == 0 || stk[len-1] == '<' { stk.push(S[i]); cnt = 0; } else { let mut x = stk.pop().unwrap(); while x == '=' { x = stk.pop().unwrap(); } cnt -= 1; } } } println!("{}", stk.len()); }