結果
問題 | No.1292 パタパタ三角形 |
ユーザー |
![]() |
提出日時 | 2020-11-20 21:42:45 |
言語 | Rust (1.59.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 1,907 bytes |
コンパイル時間 | 2,037 ms |
使用メモリ | 6,284 KB |
最終ジャッジ日時 | 2023-02-23 18:07:04 |
合計ジャッジ時間 | 2,914 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,248 KB |
testcase_01 | AC | 1 ms
6,184 KB |
testcase_02 | AC | 1 ms
6,204 KB |
testcase_03 | AC | 0 ms
6,252 KB |
testcase_04 | AC | 1 ms
6,268 KB |
testcase_05 | AC | 1 ms
6,204 KB |
testcase_06 | AC | 1 ms
6,268 KB |
testcase_07 | AC | 21 ms
6,284 KB |
testcase_08 | AC | 20 ms
6,276 KB |
testcase_09 | AC | 11 ms
6,196 KB |
testcase_10 | AC | 12 ms
6,252 KB |
testcase_11 | AC | 11 ms
6,284 KB |
testcase_12 | AC | 5 ms
6,260 KB |
testcase_13 | AC | 5 ms
6,256 KB |
testcase_14 | AC | 9 ms
6,252 KB |
testcase_15 | AC | 9 ms
6,200 KB |
testcase_16 | AC | 9 ms
6,204 KB |
コンパイルメッセージ
warning: function is never used: `read_vec` --> Main.rs:75:4 | 75 | fn read_vec<T: std::str::FromStr>() -> Vec<T> { | ^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: 1 warning emitted
ソースコード
#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let s = read::<String>() .chars() .map(|ch| ch.to_digit(36).unwrap() as usize - 10) .collect::<Vec<_>>(); let mut state = (2, 0); // 0: a, 1: b, 2: c let mut cur = (0, 0); let mut entried = vec![(0, 0)]; for ch in s { if ch == state.0 { if state.1 == 0 { cur.1 -= 1; } else { cur.1 += 1; } } else if state.0 == 2 { if ch == 1 { cur.0 += 1; state.0 = 0; } else { cur.0 -= 1; state.0 = 1; } } else if state.0 == 1 { if ch == 0 { cur.0 += 1; state.0 = 2; } else { cur.0 -= 1; state.0 = 0; } } else if state.0 == 0 { if ch == 2 { cur.0 += 1; state.0 = 1; } else { cur.0 -= 1; state.0 = 2; } } state.1 = 1 - state.1; entried.push(cur); } entried.sort(); entried.dedup(); // debug!(entried); println!("{}", entried.len()); } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }