| Task: | Monikulmio |
| Sender: | ma100 |
| Submission time: | 2025-10-28 14:18:20 +0200 |
| Language: | Rust (2021) |
| Status: | READY |
| Result: | 21 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 21 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 7 | details |
| #2 | ACCEPTED | 0.00 s | 7 | details |
| #3 | RUNTIME ERROR | 0.00 s | 0 | details |
| #4 | RUNTIME ERROR | 0.00 s | 0 | details |
| #5 | RUNTIME ERROR | 0.00 s | 0 | details |
| #6 | RUNTIME ERROR | 0.00 s | 0 | details |
| #7 | RUNTIME ERROR | 0.00 s | 0 | details |
| #8 | RUNTIME ERROR | 0.00 s | 0 | details |
| #9 | ACCEPTED | 0.00 s | 7 | details |
| #10 | RUNTIME ERROR | 0.00 s | 0 | details |
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 emittedCode
use std::{io, vec};
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 {
for i in 1..(b.0-a.0) {
grid[a.1-i][a.0+i] = Pixel::Line45R;
}
}
} else { // 45
panic!("unimplemented");
}
}
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: RUNTIME ERROR
| 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:58:9: unimplemented note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 4 (public)
Verdict: RUNTIME ERROR
| 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:58:9: unimplemented note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 5 (public)
Verdict: RUNTIME ERROR
| 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:58:9: unimplemented note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 6 (public)
Verdict: RUNTIME ERROR
| 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:58:9: unimplemented note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 7 (public)
Verdict: RUNTIME ERROR
| 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:58:9: unimplemented note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 8 (public)
Verdict: RUNTIME ERROR
| 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:58:9: unimplemented note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
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: RUNTIME ERROR
| 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:58:9: unimplemented note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
