| Task: | Robotti |
| Sender: | asonnine |
| Submission time: | 2026-01-17 13:17:44 +0200 |
| Language: | Rust (2021) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 100 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | ACCEPTED | 0.01 s | details |
Compiler report
warning: comparison is useless due to type limits
--> input/code.rs:23:12
|
23 | if pos.0 < 0 || pos.1 < 0 || pos.0 >= n || pos.1 >= n {
| ^^^^^^^^^
|
= note: `#[warn(unused_comparisons)]` on by default
warning: comparison is useless due to type limits
--> input/code.rs:23:25
|
23 | if pos.0 < 0 || pos.1 < 0 || pos.0 >= n || pos.1 >= n {
| ^^^^^^^^^
warning: 2 warnings emittedCode
enum Direction {
Up,
Down,
Left,
Right
}
fn main() {
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let n: usize = input.trim().parse().unwrap();
let mut grid: Vec<Vec<char>> = Vec::new();
for _ in 0..n {
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
grid.push(input.chars().collect());
}
let mut counter = 0;
let mut pos = (0, 0);
let mut dir = Direction::Down;
loop {
if pos.0 < 0 || pos.1 < 0 || pos.0 >= n || pos.1 >= n {
break;
}
counter += 1;
match grid[pos.1][pos.0] {
'.' => {}
'/' => {dir = match dir {
Direction::Up => Direction::Right,
Direction::Down => Direction::Left,
Direction::Left => Direction::Down,
Direction::Right => Direction::Up,
};
grid[pos.1][pos.0] = '\\';
},
'\\' => {dir = match dir {
Direction::Up => Direction::Left,
Direction::Down => Direction::Right,
Direction::Left => Direction::Up,
Direction::Right => Direction::Down,
};
grid[pos.1][pos.0] = '/';
}
_ => panic!(),
}
match dir {
Direction::Up => pos.1 -= 1,
Direction::Down => pos.1 += 1,
Direction::Left => pos.0 -= 1,
Direction::Right => pos.0 += 1,
}
}
println!("{counter}");
}
Test details
Test 1 (public)
Verdict: ACCEPTED
| input |
|---|
| 3 ./\ \./ \/. |
| correct output |
|---|
| 13 |
| user output |
|---|
| 13 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 1 . |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 5 ./\/\ ..... ..... ..... ... |
| correct output |
|---|
| 25 |
| user output |
|---|
| 25 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 5 \\/\\ /\/\/ \\/\\ /\/\/ ... |
| correct output |
|---|
| 37 |
| user output |
|---|
| 37 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 20 \\/\/\/\\./\\.\/\/\. /\\\\\\/\\\\\\\\\\\. \\\\\\\\\\\\\\\\\\\\ /\\\\\\\\\\\\\.\\\\\ ... |
| correct output |
|---|
| 2519 |
| user output |
|---|
| 2519 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 20 \\.................. .\\..............\\. ..\\............\\.. ...\\..........\\... ... |
| correct output |
|---|
| 917489 |
| user output |
|---|
| 917489 |
