| Task: | Monikulmio |
| Sender: | madde |
| Submission time: | 2025-10-28 19:32:30 +0200 |
| Language: | Rust (2021) |
| Status: | READY |
| Result: | 70 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 70 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 7 | details |
| #2 | ACCEPTED | 0.00 s | 7 | details |
| #3 | ACCEPTED | 0.00 s | 7 | details |
| #4 | ACCEPTED | 0.00 s | 7 | details |
| #5 | ACCEPTED | 0.00 s | 7 | details |
| #6 | ACCEPTED | 0.00 s | 7 | details |
| #7 | ACCEPTED | 0.00 s | 7 | details |
| #8 | ACCEPTED | 0.00 s | 7 | details |
| #9 | ACCEPTED | 0.00 s | 7 | details |
| #10 | ACCEPTED | 0.00 s | 7 | details |
Compiler report
warning: unused import: `BufRead`
--> input/code.rs:1:21
|
1 | use std::io::{self, BufRead};
| ^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: function `in_bounds` is never used
--> input/code.rs:51:4
|
51 | fn in_bounds(pos: [u32; 2], width: u32, height: u32) -> bool {
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: unused `Result` that must be used
--> input/code.rs:9:5
|
9 | input.read_line(&mut input_buf);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled
= note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
|
9 | let _ = input.read_line(&mut input_buf);
| +++++++
warning: unused `Result` that must be used
--> input/code.rs:18:9
|
18 | input.read_line(&mut input_buf);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this `Result` may be a...Code
use std::io::{self, BufRead};
// use std::time::Instant;
const X: usize = 0;
const Y: usize = 1;
fn main() {
let input = io::stdin();
let mut input_buf: String = "".to_string();
input.read_line(&mut input_buf);
let line1: Vec<&str> = input_buf.split_whitespace().collect();
// let start_time = Instant::now();
let height: u32 = line1[X].parse().unwrap();
let width: u32 = line1[Y].parse().unwrap();
let vertex_count: u32 = line1[2].parse().unwrap();
let mut vertecies: Vec<[u32; 2]> = vec![];
for _i in 0..vertex_count {
input_buf = "".to_string();
input.read_line(&mut input_buf);
input_buf = input_buf.trim().to_string();
let input_nums: Vec<&str> = input_buf.split_whitespace().collect();
let point_coord = [
input_nums[Y].parse::<u32>().unwrap(),
input_nums[X].parse::<u32>().unwrap(),
];
vertecies.push(point_coord);
}
let mut grid = draw_lines(width, height, &vertecies);
draw_dots(&mut grid, &vertecies);
print_grid(&grid);
// println!("{}", start_time.elapsed().as_millis())
}
fn draw_dots(grid: &mut Vec<Vec<char>>, vertecies: &Vec<[u32; 2]>) {
for vertex in vertecies {
draw(grid, vertex, '*');
}
}
fn print_grid(grid: &Vec<Vec<char>>) {
for line in grid.iter() {
for symbol in line.iter() {
print!("{symbol}");
}
println!("")
}
}
fn draw(grid: &mut Vec<Vec<char>>, position: &[u32; 2], thing: char) {
grid[position[Y] as usize - 1][position[X] as usize - 1] = thing;
}
fn in_bounds(pos: [u32; 2], width: u32, height: u32) -> bool {
if pos[X] < width && pos[Y] < height {
return true;
} else {
return false;
}
}
fn draw_lines(width: u32, height: u32, vertecies: &Vec<[u32; 2]>) -> Vec<Vec<char>> {
let mut grid: Vec<Vec<char>> = vec![vec!['.'; width as usize]; height as usize];
let mut cursor: [u32; 2] = [0, 0];
for i in 0..vertecies.len() {
cursor[X] = vertecies[i][X];
cursor[Y] = vertecies[i][Y];
if vertecies[i][X] == vertecies[(i + 1) % vertecies.len()][X] {
//yhtä kuin
if vertecies[i][Y] < vertecies[(i + 1) % vertecies.len()][Y] {
while cursor[Y] != vertecies[(i + 1) % vertecies.len()][Y] {
draw(&mut grid, &cursor, '|');
cursor[Y] += 1;
}
} else {
while cursor[Y] != vertecies[(i + 1) % vertecies.len()][Y] {
draw(&mut grid, &cursor, '|');
cursor[Y] -= 1;
}
}
} else if vertecies[i][X] > vertecies[(i + 1) % vertecies.len()][X] {
//suurempi
if vertecies[i][Y] < vertecies[(i + 1) % vertecies.len()][Y] {
while cursor[Y] != vertecies[(i + 1) % vertecies.len()][Y] {
draw(&mut grid, &cursor, '/');
cursor[Y] += 1;
cursor[X] -= 1;
}
} else if vertecies[i][Y] > vertecies[(i + 1) % vertecies.len()][Y] {
while cursor[Y] != vertecies[(i + 1) % vertecies.len()][Y] {
draw(&mut grid, &cursor, '\\');
cursor[Y] -= 1;
cursor[X] -= 1;
}
} else {
while cursor[X] != vertecies[(i + 1) % vertecies.len()][X] {
draw(&mut grid, &cursor, '=');
cursor[X] -= 1;
}
}
} else {
//vähempi
if vertecies[i][Y] < vertecies[(i + 1) % vertecies.len()][Y] {
while cursor[Y] != vertecies[(i + 1) % vertecies.len()][Y] {
draw(&mut grid, &cursor, '\\');
cursor[Y] += 1;
cursor[X] += 1;
}
} else if vertecies[i][Y] > vertecies[(i + 1) % vertecies.len()][Y] {
while cursor[Y] != vertecies[(i + 1) % vertecies.len()][Y] {
draw(&mut grid, &cursor, '/');
cursor[Y] -= 1;
cursor[X] += 1;
}
} else {
while cursor[X] != vertecies[(i + 1) % vertecies.len()][X] {
draw(&mut grid, &cursor, '=');
cursor[X] += 1;
}
}
}
}
return grid;
}
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 '.'
