Submission details
Task:Hypyt
Sender:Jaksu
Submission time:2025-10-30 14:00:21 +0200
Language:Rust (2021)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#10.00 s1, 2, 3, 4, 5details
#20.00 s1, 2, 3, 4, 5details
#30.00 s1, 2, 3, 4, 5details
#40.00 s1, 2, 3, 4, 5details
#50.00 s1, 2, 3, 4, 5details
#60.00 s2, 5details
#70.00 s2, 5details
#80.00 s2, 5details
#90.32 s3, 4, 5details
#100.32 s3, 4, 5details
#110.33 s3, 4, 5details
#120.33 s4, 5details
#130.34 s4, 5details
#140.32 s4, 5details
#150.33 s5details
#160.33 s5details
#170.33 s5details
#180.33 s5details
#190.33 s5details
#200.33 s5details
#210.32 s5details
#220.00 s1, 2, 3, 4, 5details
#230.00 s1, 2, 3, 4, 5details
#240.32 s5details
#250.32 s5details
#260.33 s5details
#270.32 s5details

Compiler report

warning: unused variable: `q`
  --> input/code.rs:24:9
   |
24 |     for q in 0..startdata[2] {
   |         ^ help: if this is intentional, prefix it with an underscore: `_q`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
  --> input/code.rs:49:29
   |
49 |                         let mut newcoords = vec!(rownum, coords[1], coords[2], coords[3]);
   |                             ----^^^^^^^^^
   |                             |
   |                             help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
  --> input/code.rs:58:29
   |
58 |                         let mut newcoords = vec!(coords[0], *freecell, coords[2], coords[3]);
   |                             ----^^^^^^^^^
   |                             |
   |                             help: remove this `mut`

warning: 3 warnings emitted

Code

use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("Failed to read input");

    let startdata: Vec<usize> = input.split_ascii_whitespace().map(|e| e.parse::<usize>().unwrap()).collect();
    let mut grid:Vec<Vec<usize>> = vec!();
    drop(input);

    for row in 0..startdata[0] {
        grid.push(Vec::new());

        let mut rowinput = String::new();
        io::stdin().read_line(&mut rowinput).expect("Failed to read input");
        let bytes = rowinput.into_bytes();
        for index in 0..startdata[1] {
            if bytes[index] == 46 {
                grid[row].push(index);
            }
        }
    }

    for q in 0..startdata[2] {
        let mut qinput = String::new();
        io::stdin().read_line(&mut qinput).expect("Failed to read input");
        let coords: Vec<usize> = qinput.split_ascii_whitespace().map(|e| e.parse::<usize>().unwrap()-1).collect();
        let mut rowmemory: Vec<usize> = vec!();
        let mut colmemory: Vec<usize> = vec!();

        let steps = min_step(&coords, &mut rowmemory, &mut colmemory, &grid);
        println!("{}", steps)
    }
}

pub fn min_step(coords: &Vec<usize>, rowmemory: &mut Vec<usize>, colmemory: &mut Vec<usize>, grid: &Vec<Vec<usize>>) -> isize {
    let mut output = 0;
    let mut stepvector = vec!();
    let mut found_free_cell: bool = false;
    if coords[3] == coords[1] || coords[2] == coords[0] {
        output += 1;
    } else {
        for rownum in 0..grid.len() {
            for freecell in grid[rownum].iter() {
                if rownum != coords[0] && *freecell != coords[1] {
                    if rownum == coords[0] && !rowmemory.contains(&rownum) {
                        found_free_cell = true;
                        output += 1;
                        let mut newcoords = vec!(rownum, coords[1], coords[2], coords[3]);
                        let mut newrowmemory = rowmemory.clone();
                        newrowmemory.push(coords[0]);
                        let steps = min_step(&newcoords, &mut newrowmemory, colmemory, grid);
                        stepvector.push(steps);
                    }
                    if freecell == &coords[1] && !colmemory.contains(freecell) {
                        found_free_cell = true;
                        output += 1;
                        let mut newcoords = vec!(coords[0], *freecell, coords[2], coords[3]);
                        let mut newcolmemory = colmemory.clone();
                        newcolmemory.push(coords[1]);
                        let steps = min_step(&newcoords, rowmemory, &mut newcolmemory, grid);
                        stepvector.push(steps);
                    }
                }
            }
        }
        if !found_free_cell {
            output = -1;
        }
    }
    return output;
}

Test details

Test 1 (public)

Group: 1, 2, 3, 4, 5

Verdict:

input
4 6 5
.*.***
*...**
*****.
*..*.*
...

correct output
1
0
3
3
-1

user output
1
1
-1
-1
-1

Feedback: Incorrect character on line 2 col 1: expected "0", got "1"

Test 2

Group: 1, 2, 3, 4, 5

Verdict:

input
10 10 10
..........
.....*....
........*.
*.*....*..
...

correct output
1
2
1
2
2
...

user output
1
-1
1
-1
-1
...

Feedback: Incorrect character on line 2 col 1: expected "2", got "-1"

Test 3

Group: 1, 2, 3, 4, 5

Verdict:

input
10 10 10
*...***.**
*****.*...
**..**.**.
..**.**.*.
...

correct output
1
2
2
1
2
...

user output
1
-1
-1
1
-1
...

Feedback: Incorrect character on line 2 col 1: expected "2", got "-1"

Test 4

Group: 1, 2, 3, 4, 5

Verdict:

input
10 10 10
***.*.****
**********
*.********
.*.***.**.
...

correct output
3
4
2
3
4
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "3", got "-1"

Test 5

Group: 1, 2, 3, 4, 5

Verdict:

input
10 10 1
.****.****
**.**..***
**********
*******..*
...

correct output
7

user output
-1

Feedback: Incorrect character on line 1 col 1: expected "7", got "-1"

Test 6

Group: 2, 5

Verdict:

input
250 250 250
.*...*.....*******..**...*.......

correct output
2
3
3
2
2
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"

Test 7

Group: 2, 5

Verdict:

input
250 250 250
...*......**.**.*.*..**..*..**...

correct output
2
2
2
2
3
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"

Test 8

Group: 2, 5

Verdict:

input
250 250 250
**..**..****.****.*.***.***..*...

correct output
2
3
3
3
3
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"

Test 9

Group: 3, 4, 5

Verdict:

input
40 40 200000
...*.**.*..*.............*.*.....

correct output
2
2
2
2
2
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"

Test 10

Group: 3, 4, 5

Verdict:

input
40 40 200000
**.**..*.*.*.******....****.*....

correct output
2
1
3
2
2
...

user output
-1
1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"

Test 11

Group: 3, 4, 5

Verdict:

input
40 40 200000
.*.*.**.*****.***.*.****.**.**...

correct output
3
3
3
3
3
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "3", got "-1"

Test 12

Group: 4, 5

Verdict:

input
80 80 200000
*....**.***..****...*.....*......

correct output
2
2
2
2
2
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"

Test 13

Group: 4, 5

Verdict:

input
80 80 200000
.***.*..*.***..*****....**...*...

correct output
3
2
2
3
2
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "3", got "-1"

Test 14

Group: 4, 5

Verdict:

input
80 80 200000
*******.*****.*..*..****...***...

correct output
2
3
1
2
2
...

user output
-1
-1
1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"

Test 15

Group: 5

Verdict:

input
250 250 200000
*....*..*..*..**..*.........**...

correct output
3
2
2
2
2
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "3", got "-1"

Test 16

Group: 5

Verdict:

input
250 250 200000
..*....*..*......*.**.*.*..***...

correct output
2
2
2
2
2
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"

Test 17

Group: 5

Verdict:

input
250 250 200000
*..*.*****.*********.****.****...

correct output
3
3
2
2
2
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "3", got "-1"

Test 18

Group: 5

Verdict:

input
250 250 200000
*********.**********.******.**...

correct output
3
3
3
3
3
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "3", got "-1"

Test 19

Group: 5

Verdict:

input
250 250 200000
.*****************************...

correct output
104
422
145
93
65
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "104", got "-1"

Test 20

Group: 5

Verdict:

input
250 250 200000
..****************************...

correct output
57
155
38
65
98
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "57", got "-1"

Test 21

Group: 5

Verdict:

input
250 250 200000
.*****************************...

correct output
498
498
498
498
498
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "498", got "-1"

Test 22

Group: 1, 2, 3, 4, 5

Verdict:

input
10 1 10
*
*
.
*
...

correct output
0
1
1
0
0
...

user output
1
1
1
1
1
...

Feedback: Incorrect character on line 1 col 1: expected "0", got "1"

Test 23

Group: 1, 2, 3, 4, 5

Verdict:

input
1 10 10
........*.
1 7 1 10
1 4 1 7
1 5 1 1
...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Feedback: Incorrect character on line 7 col 1: expected "0", got "1"

Test 24

Group: 5

Verdict:

input
250 1 200000
*
.
*
.
...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Feedback: Incorrect character on line 53 col 1: expected "0", got "1"

Test 25

Group: 5

Verdict:

input
1 250 200000
*.*.*...*.*.**.***..**.*.*..**...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...

Feedback: Incorrect character on line 283 col 1: expected "0", got "1"

Test 26

Group: 5

Verdict:

input
250 250 200000
.................................

correct output
2
2
2
2
2
...

user output
-1
-1
-1
-1
-1
...

Feedback: Incorrect character on line 1 col 1: expected "2", got "-1"

Test 27

Group: 5

Verdict:

input
250 250 200000
******************************...

correct output
0
0
0
0
0
...

user output
1
1
1
1
1
...

Feedback: Incorrect character on line 1 col 1: expected "0", got "1"