結果
問題 | No.3032 ホモトピー入門 |
ユーザー |
|
提出日時 | 2025-02-21 22:41:56 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 1,108 bytes |
コンパイル時間 | 13,534 ms |
コンパイル使用メモリ | 396,248 KB |
実行使用メモリ | 59,432 KB |
最終ジャッジ日時 | 2025-02-21 22:42:14 |
合計ジャッジ時間 | 16,531 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
コンパイルメッセージ
warning: unused variable: `m` --> src/main.rs:4:13 | 4 | n: usize, m: usize, | ^ help: if this is intentional, prefix it with an underscore: `_m` | = note: `#[warn(unused_variables)]` on by default
ソースコード
use proconio::{input, marker::Chars}; fn main() { input! { n: usize, m: usize, curves: [Chars; n], } let mut ans = 0; for curve in curves { let mut y = 0; let mut x = 0; let mut cross = vec![]; for c in curve { let (ny, nx) = match c { 'U' => (y + 1, x), 'D' => (y - 1, x), 'L' => (y, x - 1), 'R' => (y, x + 1), _ => unreachable!() }; if nx >= 0 && (y, ny) == (1, 0) { if cross.last() == Some(&(false, false)) { cross.pop(); } else { cross.push((false, true)); } } if nx >= 1 && (y, ny) == (0, 1) { if cross.last() == Some(&(true, false)) { cross.pop(); } else { cross.push((true, true)); } } if nx >= 1 && (y, ny) == (1, 0) { if cross.last() == Some(&(true, true)) { cross.pop(); } else { cross.push((true, false)); } } if nx >= 0 && (y, ny) == (0, 1) { if cross.last() == Some(&(false, true)) { cross.pop(); } else { cross.push((false, false)); } } x = nx; y = ny; } if cross.is_empty() { ans += 1; } } println!("{ans}"); }