Submission details
Task:Monikulmio
Sender:ma100
Submission time:2025-10-28 14:52:01 +0200
Language:Rust (2021)
Status:READY
Result:70
Feedback
groupverdictscore
#1ACCEPTED70
Test results
testverdicttimescore
#1ACCEPTED0.00 s7details
#2ACCEPTED0.00 s7details
#3ACCEPTED0.00 s7details
#4ACCEPTED0.00 s7details
#5ACCEPTED0.00 s7details
#6ACCEPTED0.00 s7details
#7ACCEPTED0.00 s7details
#8ACCEPTED0.00 s7details
#9ACCEPTED0.00 s7details
#10ACCEPTED0.00 s7details

Compiler report

warning: variant `Inside` is never constructed
  --> input/code.rs:15:5
   |
14 | enum Pixel {
   |      ----- variant in this enum
15 |     Inside,
   |     ^^^^^^
   |
   = note: `Pixel` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
   = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

Code

use std::io;

fn read_next<'a, I>(iter: &mut I) -> usize
where
    I: Iterator<Item = &'a str>,
{
    iter.next()
        .expect("invalid input")
        .parse::<usize>()
        .expect("invalid integer")
}

#[derive(Clone)]
enum Pixel {
    Inside,
    Outside,
    LineV,
    LineH,
    Line45L,
    Line45R,
    Point,
}

fn draw_line(a: (usize, usize), b: (usize, usize), grid: &mut Vec<Vec<Pixel>>) {
    if a.0 == b.0 {
        // V-line
        let range;
        if a.1 > b.1 {
            range = b.1 + 1..a.1;
        } else {
            range = a.1 + 1..b.1;
        }
        for y in range {
            grid[y][b.0] = Pixel::LineV;
        }
    } else if a.1 == b.1 {
        // H-line
        let range;
        if a.0 > b.0 {
            range = b.0 + 1..a.0;
        } else {
            range = a.0 + 1..b.0;
        }
        for x in range {
            grid[b.1][x] = Pixel::LineH;
        }
    } else if a.0 < b.0 {
        if a.1 < b.1 { // 45-L
            for i in 1..(b.0-a.0) {
                grid[a.1+i][a.0+i] = Pixel::Line45L;
            }
        } else { // 45-R
            for i in 1..(b.0-a.0) {
                grid[a.1-i][a.0+i] = Pixel::Line45R;
            }
        }
    } else { // 45
        if a.1 < b.1 { // 45-R
            for i in 1..(a.0-b.0) {
                grid[b.1-i][b.0+i] = Pixel::Line45R;
            }
        } else { // 45-L
            for i in 1..(a.0-b.0) {
                grid[b.1+i][b.0+i] = Pixel::Line45L;
            }
        }
    }
}

fn main() {
    let mut nmk = String::new();
    io::stdin()
        .read_line(&mut nmk)
        .expect("failed to read line");
    let mut nmk = nmk.split_ascii_whitespace();
    let n = read_next(&mut nmk);
    let m = read_next(&mut nmk);
    let k = read_next(&mut nmk);

    let mut xys: Vec<(usize, usize)> = Vec::with_capacity(k); // Is this required?
    let mut grid: Vec<Vec<Pixel>> = vec![vec![Pixel::Outside; m]; n];

    for i in 0..k {
        let mut xy = String::new();
        io::stdin().read_line(&mut xy).expect("failed to read line");
        let mut xy = xy.split_ascii_whitespace();
        let y = read_next(&mut xy) - 1;
        let x = read_next(&mut xy) - 1;
        let b = (x, y);
        xys.push(b);
        grid[y][x] = Pixel::Point;
        if i > 0 {
            let a = xys[i - 1];
            draw_line(a, b, &mut grid);
        }
    }
    draw_line(xys[xys.len() - 1], xys[0], &mut grid);

    for line in grid {
        for pixel in line {
            match pixel {
                Pixel::Inside => print!("#"),
                Pixel::Outside => print!("."),
                Pixel::LineH => print!("="),
                Pixel::LineV => print!("|"),
                Pixel::Line45L => print!("\\"),
                Pixel::Line45R => print!("/"),
                Pixel::Point => print!("*"),
            }
        }
        println!();
    }
}

Test details

Test 1 (public)

Verdict: ACCEPTED

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

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

user output
.........
....*....
.../.\...
../...\..
.*.....*.
...

Feedback: Lines are drawn correctly. Incorrect fill character on row 3, col 5: expected '#', got '.'

Test 2 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Feedback: Lines are drawn correctly. Incorrect fill character on row 6, col 11: expected '#', got '.'

Test 3 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Feedback: Lines are drawn correctly. Incorrect fill character on row 4, col 30: expected '#', got '.'

Test 4 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Feedback: Lines are drawn correctly. Incorrect fill character on row 4, col 10: expected '#', got '.'

Test 5 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Feedback: Lines are drawn correctly. Incorrect fill character on row 4, col 20: expected '#', got '.'

Test 6 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Feedback: Lines are drawn correctly. Incorrect fill character on row 3, col 3: expected '#', got '.'

Test 7 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Feedback: Lines are drawn correctly. Incorrect fill character on row 7, col 10: expected '#', got '.'

Test 8 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Feedback: Lines are drawn correctly. Incorrect fill character on row 3, col 30: expected '#', got '.'

Test 9 (public)

Verdict: ACCEPTED

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

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

user output
*=====*===*==*...................

Feedback: Lines are drawn correctly. Incorrect fill character on row 2, col 11: expected '#', got '.'

Test 10 (public)

Verdict: ACCEPTED

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

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

user output
...*====*........................

Feedback: Lines are drawn correctly. Incorrect fill character on row 2, col 6: expected '#', got '.'