| Task: | Monikulmio |
| Sender: | Jaksu |
| Submission time: | 2025-10-28 00:30:05 +0200 |
| Language: | Rust (2021) |
| Status: | READY |
| Result: | 73 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 73 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 7 | details |
| #2 | ACCEPTED | 0.00 s | 10 | 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: 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: 1 warning 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;
}
fill_horizontal(&mut grid, width, height);
fill_vertical(&mut grid, width, height);
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 fill_horizontal(grid: &mut Vec<Vec<u8>>, width: usize, height: usize) {
let mut edges: usize = 0;
for rownum in 0..height {
for colnum in 0..width {
let char = grid[rownum][colnum];
if char != 61 && char != 42 && char != 46 && char != 35 {
edges += 1;
}
if edges%2 == 1 && char == 46 {
grid[rownum][colnum] = 35;
}
}
}
}
pub fn fill_vertical(grid: &mut Vec<Vec<u8>>, width: usize, height: usize) {
for colnum in 0..width {
let mut edges = 0;
for rownum in 0..height {
let char = grid[rownum][colnum];
if char != 124 && char != 42 && char != 46 && char != 35 {
edges += 1
}
if edges%2 == 1 && char == 46 {
grid[rownum][colnum] = 35;
}
}
}
}
/*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 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: 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 5, 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 |
|---|
| ................................. |
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 8, 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 6, col 25: 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 7, 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 19: 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 15: 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 9: expected '.', got '#'
