結果
| 問題 |
No.3032 ホモトピー入門
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-21 22:39:00 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,108 bytes |
| コンパイル時間 | 12,882 ms |
| コンパイル使用メモリ | 391,268 KB |
| 実行使用メモリ | 59,556 KB |
| 最終ジャッジ日時 | 2025-02-21 22:39:17 |
| 合計ジャッジ時間 | 16,361 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 15 WA * 22 |
コンパイルメッセージ
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 >= 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));
}
}
if nx >= 0 && (y, ny) == (1, 0) {
if cross.last() == Some(&(false, false)) {
cross.pop();
} else {
cross.push((false, true));
}
}
x = nx;
y = ny;
}
if cross.is_empty() {
ans += 1;
}
}
println!("{ans}");
}