結果
問題 |
No.2924 <===Super Spaceship String===>
|
ユーザー |
![]() |
提出日時 | 2024-09-26 06:13:35 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 999 bytes |
コンパイル時間 | 13,118 ms |
コンパイル使用メモリ | 378,104 KB |
実行使用メモリ | 16,896 KB |
最終ジャッジ日時 | 2024-10-12 07:57:09 |
合計ジャッジ時間 | 14,036 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 5 |
ソースコード
use proconio::input; use proconio::fastout; use proconio::marker::Chars; #[fastout] #[allow(non_snake_case)] fn main() { input! { S: Chars, } assert!(1 <= S.len() && S.len() <= 500_000); let mut T = Vec::new(); let mut cnt = 0; for i in 0..S.len() { assert!(S[i] == '<' || S[i] == '>' || S[i] == '='); if S[i] == '=' { cnt += 1; } else { if cnt > 0 { T.push(('=', cnt)); cnt = 0; } T.push((S[i], 1)); } } if cnt > 0 { T.push(('=', cnt)); } let mut stc = Vec::new(); for i in 0..T.len() { stc.push(T[i]); if stc.len() < 3 { continue; } let n = stc.len(); if stc[n-3].0 == '<' && stc[n-2].0 == '=' && stc[n-1].0 == '>' { for _ in 0..3 { stc.pop(); } } } println!("{}", stc.iter().map(|&x| x.1).sum::<usize>()); }