| Task: | Monikulmio |
| Sender: | vulpesomnia |
| Submission time: | 2025-10-27 13:51:51 +0200 |
| Language: | Rust (2021) |
| Status: | READY |
| Result: | 76 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 76 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 10 | 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 | 10 | 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.01 s | 7 | details |
| #10 | ACCEPTED | 0.03 s | 7 | details |
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:80:25
|
80 | 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 is_special: bool = false;
let mut is_up: bool = false;
let mut line = String::new();
'row: for j in 0..m {
for (x, y) in &points {
if (j + 1, i + 1) == (*x, *y) {
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 {
if dx1 == 0 {
inside = !inside;
}
} else {
if dy1 != dy2 {
if (dy1 == 0 || dy2 == 0) && !is_special {
is_special = !is_special;
is_up = if dy1 == 1 || dy2 == 1 {true} else {false};
inside = !inside;
} else if is_special {
if is_up && (dy1 == 1 || dy2 == 1) {
inside = !inside;
}
is_special = false;
} else {
inside = !inside;
}
}
}
line.push('*');
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;
continue 'row;
}
}
for (x, y) in &ascending {
if (j + 1, i + 1) == (*x, *y) {
line.push('/');
inside = !inside;
continue 'row;
}
}
for (x, y) in &descending {
if (j + 1, i + 1) == (*x, *y) {
line.push('\\');
inside = !inside;
continue 'row;
}
}
if inside {
line.push('#');
} else {
line.push('.');
}
}
println!("{}", line);
}
}
Test details
Test 1 (public)
Verdict: ACCEPTED
| input |
|---|
| 8 9 5 5 2 2 5 5 8 7 8 ... |
| correct output |
|---|
| ......... ....*.... .../#\... ../###\.. .*#####*. ... |
| user output |
|---|
| ......... ....*.... .../#\... ../###\.. .*#####*. ... |
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 5, col 31: 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 12, col 23: 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 3, col 27: expected '.', got '#'
Test 5 (public)
Verdict: ACCEPTED
| input |
|---|
| 20 40 12 3 20 7 16 7 9 11 13 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
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 2, col 9: 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 6, col 15: 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 17, col 10: 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 1, 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 1, col 10: expected '.', got '#'
