Submission details
Task:Monikulmio
Sender:Jaksu
Submission time:2025-10-28 09:05:10 +0200
Language:Rust (2021)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#10.00 s0details
#20.00 s0details
#30.00 s0details
#40.00 s0details
#50.00 s0details
#60.00 s0details
#70.00 s0details
#80.00 s0details
#90.51 s0details
#100.00 s0details

Compiler report

warning: value assigned to `point` is never read
  --> input/code.rs:19:13
   |
19 |     let mut point = (0,0);
   |             ^^^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

warning: unused comparison that must be used
   --> input/code.rs:113:9
    |
113 |         grid[point.0][point.1] == 35;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the comparison produces a value
    |
    = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
    |
113 |         let _ = grid[point.0][point.1] == 35;
    |         +++++++

warning: 2 warnings emitted

Code

use std::{io, str::SplitAsciiWhitespace};
pub fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("Failed to read input");
    
    let mut substringiter = input.split_ascii_whitespace();
    
    let height = parse(&mut substringiter);
    let width = parse(&mut substringiter);
    let mut grid: Vec<Vec<u8>> = vec!();
    let rowtext = ".".repeat(width);
    for _rownum in 0..height {
        grid.push(rowtext.as_bytes().to_vec());
    }

    let pointamount = parse(&mut substringiter);
    let mut previouspoint = (0, 0);
    let mut firstpoint = (0, 0);
    let mut point = (0,0);

    for index in 0..(pointamount+1) {
        if index != pointamount {
            point = get_point();
        } else {
            point = firstpoint;
        }

        grid[point.0][point.1] = 42;

        if index != 0 {
            let dy = point.0 as isize - previouspoint.0 as isize;
            let dx = point.1 as isize - previouspoint.1 as isize;

            if dx == 0 {
                let rangey = range(previouspoint.0, point.0);
                for rownum in rangey {
                    grid[rownum][point.1] = 124;
                }
            } else {
                let kulmakerroin = dy/dx;
                let character: u8 = match kulmakerroin {
                    1 => 92,
                    0 => 61,
                    -1 => 47,
                    _ => 0,
                };

                let rangex = range(previouspoint.1, point.1);

                for column in rangex {
                    let y = (previouspoint.0 as isize +(column as isize -previouspoint.1 as isize)*kulmakerroin) as usize;
                    grid[y][column] = character;
                }
            }
        } else {
            firstpoint = point;
        }

        previouspoint = point;
    }

    let startpoint = find_inside(&grid);

    fill(&mut grid, startpoint);

    printresult(&grid);
}

pub fn parse(iter: &mut SplitAsciiWhitespace) -> usize {
    let s = match iter.next() {
        Some(s) => s.parse().unwrap(),
        None => 0,
    };
    return s;
}

pub fn range(previouspointcoord: usize, pointcoord: usize) -> std::ops::Range<usize> {
    let range: std::ops::Range<usize> = match pointcoord > previouspointcoord {
        true => (previouspointcoord+1)..pointcoord,
        false => (pointcoord+1)..previouspointcoord,
    };
    return range;
}

pub fn get_point() -> (usize, usize) {
    let mut point = String::new();
    io::stdin().read_line(&mut point).expect("Failed to read input");

    let mut pointiter = point.split_ascii_whitespace();
    let y = parse(&mut pointiter)-1;
    let x = parse(&mut pointiter)-1;
    let output = (y, x);
    return output;
}

pub fn find_inside(grid: &Vec<Vec<u8>>) -> (usize, usize) {
    let mut output: (usize, usize) = (0, 0);
    for rownum in 0..grid.len() {
        for colnum in 0..grid[rownum].len() {
            let char = grid[rownum][colnum];
            if char != 61 && char != 42 && char != 46 {
                if grid[rownum][colnum+1] == 46 && grid[rownum+1][colnum+1] == 46 && grid[rownum-1][colnum+1] == 46 {
                    output = (rownum, colnum+1);
                }
            }
        }
    }
    return output;
}

pub fn fill(grid: &mut Vec<Vec<u8>>, point: (usize, usize)) {
    if grid[point.0][point.1] == 46 {
        grid[point.0][point.1] == 35;
        fill(grid, (point.0+1, point.1));
        fill(grid, (point.0, point.1-1));
        fill(grid, (point.0+1, point.1));
        fill(grid, (point.0-1, point.1));
    }

} 

pub fn printresult(grid: &Vec<Vec<u8>>) {
    let mut stringgrid: Vec<&str> = vec!();
    for row in grid {
        let charrow = &row[..];
        let s = match std::str::from_utf8(charrow) {
            Ok(v) => v,
            Err(_e) => panic!(),
        };
        stringgrid.push(s);
    }

    for row in stringgrid {
        println!("{}", row);
    }
}

Test details

Test 1 (public)

Verdict:

input
8 9 5
5 2
2 5
5 8
7 8
...

correct output
.........
....*....
.../#\...
../###\..
.*#####*.
...

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:112:12:
index out of bounds: the len is 8 but the index is 8
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 2 (public)

Verdict:

input
20 40 4
5 10
5 30
15 30
15 10

correct output
.................................

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:112:12:
index out of bounds: the len is 20 but the index is 20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 3 (public)

Verdict:

input
20 40 29
8 7
13 2
14 2
9 7
...

correct output
.................................

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:112:12:
index out of bounds: the len is 20 but the index is 20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 4 (public)

Verdict:

input
20 40 14
5 12
5 25
8 28
13 28
...

correct output
.................................

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:112:12:
index out of bounds: the len is 20 but the index is 20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 5 (public)

Verdict:

input
20 40 12
3 20
7 16
7 9
11 13
...

correct output
.................................

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:112:12:
index out of bounds: the len is 20 but the index is 20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 6 (public)

Verdict:

input
9 35 33
2 3
2 8
4 8
4 5
...

correct output
.................................

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:112:12:
index out of bounds: the len is 9 but the index is 9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 7 (public)

Verdict:

input
30 100 69
6 10
6 14
7 14
7 18
...

correct output
.................................

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:102:32:
index out of bounds: the len is 100 but the index is 100
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 8 (public)

Verdict:

input
40 60 192
11 3
11 5
10 6
11 7
...

correct output
.................................

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:112:12:
index out of bounds: the len is 40 but the index is 40
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 9 (public)

Verdict:

input
50 100 142
1 1
1 7
1 11
1 14
...

correct output
*=====*===*==*...................

user output
(empty)

Test 10 (public)

Verdict:

input
100 100 1000
10 1
4 7
1 4
1 9
...

correct output
...*====*........................

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:102:32:
index out of bounds: the len is 100 but the index is 100
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace