結果
| 問題 |
No.457 (^^*)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-21 20:20:11 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 137 ms / 2,000 ms |
| コード長 | 1,523 bytes |
| コンパイル時間 | 13,552 ms |
| コンパイル使用メモリ | 402,076 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 18:20:37 |
| 合計ジャッジ時間 | 13,765 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
fn get_result(s: &str, idx: usize, right: usize) -> (usize, usize) {
let mut right = right;
let mut left_eye: usize = 0;
let mut left_asta: usize = 0;
let mut right_eye: usize = 0;
let mut right_asta: usize = 0;
let mut left_result: usize = 0;
let mut right_result: usize = 0;
for c in s.trim().chars().skip(idx) {
match c {
'*' => {
if right_asta == 0 { right_asta += 1; }
if left_eye > 1 { left_asta += 1; }
if left_asta == 1 { left_result = right; }
},
'^' => {
if left_eye < 2 { left_eye += 1; }
if right_asta > 0 { right_eye += 1; }
if right_eye == 2 { right_result = right; }
},
')' => { right -= 1; },
_ => {}
}
};
(left_result, right_result)
}
fn main() {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
let mut rightb: usize = s.trim().chars().filter(|&c| c == ')').count();
let mut resultl: usize = 0;
let mut resultr: usize = 0;
s.trim().chars().enumerate().for_each(|pair| {
let c = pair.1;
let idx = pair.0;
match c {
'(' => {
let result = get_result(s.trim(), idx, rightb);
resultl += result.0;
resultr += result.1;
},
')' => { rightb -= 1; },
_ => {}
}
});
println!("{} {}", resultl, resultr);
}