Submission details
Task:Monikulmio
Sender:vulpesomnia
Submission time:2025-10-27 12:47:08 +0200
Language:Rust (2021)
Status:READY
Result:17
Feedback
groupverdictscore
#117
Test results
testverdicttimescore
#10.00 s0details
#2ACCEPTED0.00 s10details
#30.00 s0details
#4ACCEPTED0.00 s7details
#50.00 s0details
#60.00 s0details
#70.00 s0details
#80.00 s0details
#90.01 s0details
#100.03 s0details

Compiler report

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

warning: unused variable: `j`
  --> input/code.rs:44:17
   |
44 |             for j in 0..dy.abs() {
   |                 ^ help: if this is intentional, prefix it with an underscore: `_j`

warning: unused variable: `j`
  --> input/code.rs:51:17
   |
51 |             for j in 0..dx.abs() {
   |                 ^ help: if this is intentional, prefix it with an underscore: `_j`

warning: unused variable: `j`
  --> input/code.rs:61:17
   |
61 |             for j in 0..dx.abs() {
   |                 ^ help: if this is intentional, prefix it with an underscore: `_j`

warning: variable does not need to be mutable
  --> input/code.rs:82:25
   |
82 |                     let mut index = points.iter().position(|&a| a == (*x, *y)).unwrap();
   |                         ----^^...

Code

use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("failed to readline");
    let mut iter = input.trim().split_whitespace();
    let (n, m, k): (i32, i32, i32) = (
        iter.next().unwrap().parse().unwrap(),
        iter.next().unwrap().parse().unwrap(),
        iter.next().unwrap().parse().unwrap(),
    );
    
    let mut points: Vec<(i32, i32)> = Vec::new();
    for i in 0..k {
        let mut point = String::new();
        io::stdin().read_line(&mut point).expect("failed to readline");
        let mut iter2 = point.trim().split_whitespace();
        let (y, x): (i32, i32) = (
            iter2.next().unwrap().parse().unwrap(),
            iter2.next().unwrap().parse().unwrap(),
        );
        points.push((x, y));
    }

    let mut descending: Vec<(i32, i32)> = Vec::new();
    let mut ascending: Vec<(i32, i32)> = Vec::new();
    let mut horizontal: Vec<(i32, i32)> = Vec::new();
    let mut vertical: Vec<(i32, i32)> = Vec::new();
    
    let size = points.len();
    for (i, (px, py)) in points.clone().into_iter().enumerate() {
        let p1: (i32, i32) = (px, py);
        let p2: (i32, i32);
        if i == size - 1 {
            p2 = points[0];
        } else {
            p2 = points[i+1];
        }
        let dx = p2.0 - p1.0;
        let dy = p2.1 - p1.1;
        if dx == 0 { // Vertical
            let mut ny = p1.1;
            let step = dy/(dy.abs());
            for j in 0..dy.abs() {
                vertical.push((p1.0, ny));
                ny += step;
            }
        } else if dy == 0 { // Horizontal
            let mut nx = p1.0;
            let step = dx/(dx.abs());
            for j in 0..dx.abs() {
                horizontal.push((nx ,p1.1));
                nx += step;
            }
        } else {
            let k = dy/dx;
            let mut nx = p1.0;
            let mut ny = p1.1;
            let step_x = dx/(dx.abs());
            let step_y = dy/(dy.abs());
            for j in 0..dx.abs() {
                if k == -1 { // Ascending
                    ascending.push((nx ,ny));
                } else {
                    descending.push((nx ,ny));
                }
                nx += step_x;
                ny += step_y;
            }
        }
    }
    for i in 0..n {
        let mut inside: bool = false;
        let mut count_inside: bool = false;
        let mut inside_counter: usize = 0;
        let mut line = String::new();
        'row: for j in 0..m {
            for (x, y) in &points {
                if (j + 1, i + 1) == (*x, *y) {
                    line.push('*');

                    let mut index = points.iter().position(|&a| a == (*x, *y)).unwrap();
                    let (mut p1, mut p2);
                    if index == 0 {
                        p1 = points[size - 1];
                    } else {
                        p1 = points[index - 1];
                    }

                    if index == size - 1 {
                        p2 = points[0];
                    } else {
                        p2 = points[index + 1];
                    }

                    let mut dx1 = x - p1.0;
                    let mut dx2 = x - p2.0;
                    let mut dy1 = y - p1.1;
                    let mut dy2 = y - p2.1;
                    let dx1 = if dx1 == 0 {0} else {dx1/(dx1.abs())};
                    let dx2 = if dx2 == 0 {0} else {dx2/(dx2.abs())};
                    let dy1 = if dy1 == 0 {0} else {dy1/(dy1.abs())};
                    let dy2 = if dy2 == 0 {0} else {dy2/(dy2.abs())};
                    if dx1 == dx2 && dy1 == dy2 {
                        inside = !inside;
                        count_inside = false;
                    } else {
                        count_inside = !count_inside;
                    }
                    continue 'row;
                }
            }
            for (x, y) in &horizontal {
                if (j + 1, i + 1) == (*x, *y) {
                    line.push('=');
                    continue 'row;
                }
            }
            for (x, y) in &vertical {
                if (j + 1, i + 1) == (*x, *y) {
                    line.push('|');
                    inside = !inside;
                    count_inside = false;
                    continue 'row;
                }
            }
            for (x, y) in &ascending {
                if (j + 1, i + 1) == (*x, *y) {
                    line.push('/');
                    inside = !inside;
                    count_inside = false;
                    continue 'row;
                }
            }
            for (x, y) in &descending {
                if (j + 1, i + 1) == (*x, *y) {
                    line.push('\\');
                    inside = !inside;
                    count_inside = false;
                    continue 'row;
                }
            }
            if inside || count_inside {
                line.push('#');
                if count_inside {
                    inside_counter += 1;
                }
            } else {
                line.push('.');
            }
        }
        if count_inside == true {
            line.replace_range((line.len() - inside_counter)..(line.len()), &".".repeat(inside_counter+1));
        }
        println!("{}", line);
    }

    
}

Test details

Test 1 (public)

Verdict:

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

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

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

Feedback: Incorrect length on line 2: expected 9, got 10

Test 2 (public)

Verdict: ACCEPTED

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

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

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

Test 3 (public)

Verdict:

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

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

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

Feedback: Incorrect length on line 12: expected 40, got 41

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 16, col 26: expected '#', got '.'

Test 5 (public)

Verdict:

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

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

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

Feedback: Incorrect length on line 3: expected 40, got 41

Test 6 (public)

Verdict:

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

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

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

Feedback: Incorrect length on line 5: expected 35, got 36

Test 7 (public)

Verdict:

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

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

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

Feedback: Incorrect length on line 13: expected 100, got 101

Test 8 (public)

Verdict:

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

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

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

Feedback: Incorrect length on line 2: expected 60, got 61

Test 9 (public)

Verdict:

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

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

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

Feedback: Incorrect length on line 7: expected 100, got 101

Test 10 (public)

Verdict:

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

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

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

Feedback: Incorrect length on line 6: expected 100, got 101