| Task: | Monikulmio |
| Sender: | _maoe |
| Submission time: | 2025-10-29 22:12:24 +0200 |
| Language: | Rust (2021) |
| Status: | READY |
| Result: | 30 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 30 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 10 | details |
| #2 | ACCEPTED | 0.00 s | 10 | 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 | ACCEPTED | 0.00 s | 10 | details |
| #8 | RUNTIME ERROR | 0.00 s | 0 | details |
| #9 | RUNTIME ERROR | 0.00 s | 0 | details |
| #10 | RUNTIME ERROR | 0.00 s | 0 | details |
Code
use std::{cmp, io};
fn main() {
let mut syote = String::new();
io::stdin().read_line(&mut syote).expect("RAAAAAAAAAAA!!");
let mut lahtoarvot = syote.split_whitespace();
// unhggggggggggggghhhhhhhhh
let n = lahtoarvot.next().unwrap().parse::<usize>().unwrap();
let m = lahtoarvot.next().unwrap().parse::<usize>().unwrap();
let k = lahtoarvot.next().unwrap().parse::<usize>().unwrap();
let mut karkipisteet: Vec<[u16; 2]> = Vec::with_capacity(k);
//ngnnhhhhhhhhhhhhhhhhhhhhhhhhhhhhh..
syote = String::new();
for _ in 0..k {
io::stdin().read_line(&mut syote).expect("hups");
}
let mut pisteet = syote.split_whitespace();
for _ in 0..k {
karkipisteet.push([
pisteet.next().unwrap().parse::<u16>().unwrap() - 1,
pisteet.next().unwrap().parse::<u16>().unwrap() - 1,
]);
}
// hehee sain välltettyy 2 min työtä
karkipisteet.push([karkipisteet[0][0], karkipisteet[0][1]]);
/*
# = 35
* = 42
. = 46
/ = 47
= = 61
\ = 92
| = 124
*/
let mut matriisi: Vec<Vec<u8>> = vec![vec![46; m]; n];
let mut indeksi: u16;
// joo täs kuuluis olla funktioi mut aivsama e jaks
for i in 0..(karkipisteet.len() - 1) {
// hyi
matriisi[karkipisteet[i][0] as usize][karkipisteet[i][1] as usize] = 42;
match karkipisteet[i + 1][1].cmp(&karkipisteet[i][1]) {
cmp::Ordering::Greater => {
match karkipisteet[i + 1][0].cmp(&karkipisteet[i][0]) {
cmp::Ordering::Greater => {
indeksi = 1;
while karkipisteet[i][0] + indeksi < karkipisteet[i + 1][0] {
// Hyyi
matriisi[(karkipisteet[i][0] + indeksi) as usize]
[(karkipisteet[i][1] + indeksi) as usize] = 92;
indeksi += 1
}
}
cmp::Ordering::Less => {
indeksi = 1;
while karkipisteet[i][0] - indeksi > karkipisteet[i + 1][0] {
dbg!(indeksi);
matriisi[(karkipisteet[i][0] - indeksi) as usize]
[(karkipisteet[i][1] + indeksi) as usize] = 47;
indeksi += 1
}
}
cmp::Ordering::Equal => {
indeksi = 1;
while karkipisteet[i][1] + indeksi < karkipisteet[i + 1][1] {
matriisi[(karkipisteet[i][0]) as usize]
[(karkipisteet[i][1] + indeksi) as usize] = 61;
indeksi += 1
}
}
}
}
cmp::Ordering::Equal => match karkipisteet[i + 1][0].cmp(&karkipisteet[i][0]) {
cmp::Ordering::Greater => {
indeksi = 1;
while karkipisteet[i][0] + indeksi < karkipisteet[i + 1][0] {
matriisi[(karkipisteet[i][0] + indeksi) as usize]
[(karkipisteet[i][1]) as usize] = 124;
indeksi += 1;
}
}
cmp::Ordering::Less => {
indeksi = 1;
while karkipisteet[i][0] - indeksi > karkipisteet[i + 1][0] {
matriisi[(karkipisteet[i][0] - indeksi) as usize]
[(karkipisteet[i][1]) as usize] = 124;
indeksi += 1
}
}
cmp::Ordering::Equal => {} // älä tee mitään
},
cmp::Ordering::Less => match karkipisteet[i + 1][0].cmp(&karkipisteet[i][0]) {
cmp::Ordering::Greater => {
indeksi = 1;
while karkipisteet[i][0] + indeksi < karkipisteet[i + 1][0] {
matriisi[(karkipisteet[i][0] + indeksi) as usize]
[(karkipisteet[i][1] - indeksi) as usize] = 47;
indeksi += 1
}
}
cmp::Ordering::Less => {
indeksi = 1;
while karkipisteet[i][0] - indeksi > karkipisteet[i + 1][0] {
matriisi[(karkipisteet[i][0] - indeksi) as usize]
[(karkipisteet[i][1] - indeksi) as usize] = 92;
indeksi += 1
}
}
cmp::Ordering::Equal => {
indeksi = 1;
while karkipisteet[i][1] - indeksi > karkipisteet[i + 1][1] {
matriisi[(karkipisteet[i][0]) as usize]
[(karkipisteet[i][1] - indeksi) as usize] = 61;
indeksi += 1
}
}
},
}
}
for rivi in 0..n - 1 {
let mut i: usize = 0;
while i < m - 2 {
if matches!(matriisi[rivi as usize][i], 47 | 92 | 124) {
loop {
i += 1;
match matriisi[rivi as usize][i] {
46 => matriisi[rivi as usize][i] = 35,
_ => break,
}
}
} else if matriisi[rivi as usize][i] == 42 && matriisi[(rivi - 1) as usize][i + 1] != 46
{
loop {
i += 1;
match matriisi[rivi as usize][i] {
46 => matriisi[rivi as usize][i] = 35,
_ => break,
}
}
}
i += 1
}
}
let mut tuloste: String = String::new();
for rivi in matriisi {
tuloste.push_str(&String::from_utf8(rivi).unwrap());
tuloste.push('\n');
}
println!("{tuloste}")
}
Test details
Test 1 (public)
Verdict: ACCEPTED
| input |
|---|
| 8 9 5 5 2 2 5 5 8 7 8 ... |
| correct output |
|---|
| ......... ....*.... .../#\... ../###\.. .*#####*. ... |
| user output |
|---|
| ......... ....*.... .../#\... ../###\.. .*#####*. ... |
Error:
[input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2
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: RUNTIME ERROR
| input |
|---|
| 20 40 29 8 7 13 2 14 2 9 7 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Error:
[input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 [input/code.rs:61] indeksi = 4 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 [input/code.rs:61] indeksi = 1 thread 'main' panicked at input/code.rs:131:50: index out of bounds: the len is 40 but the index is 40 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:
[input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 [input/code.rs:61] indeksi = 4 thread 'main' panicked at input/code.rs:140:50: index out of bounds: the len is 40 but the index is 40 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:
[input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 thread 'main' panicked at input/code.rs:140:50: index out of bounds: the len is 40 but the index is 40 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:140:50: index out of bounds: the len is 35 but the index is 35 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 7 (public)
Verdict: ACCEPTED
| input |
|---|
| 30 100 69 6 10 6 14 7 14 7 18 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
Error:
[input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2
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:140:50: index out of bounds: the len is 60 but the index is 60 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 9 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 50 100 142 1 1 1 7 1 11 1 14 ... |
| correct output |
|---|
| *=====*===*==*................... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:136:67: index out of bounds: the len is 50 but the index is 18446744073709551615 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 10 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 100 100 1000 10 1 4 7 1 4 1 9 ... |
| correct output |
|---|
| ...*====*........................ |
| user output |
|---|
| (empty) |
Error:
[input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 [input/code.rs:61] indeksi = 4 [input/code.rs:61] indeksi = 5 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 [input/code.rs:61] indeksi = 4 [input/code.rs:61] indeksi = 5 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 [input/code.rs:61] indeksi = 4 [input/code.rs:61] indeksi = 5 [input/code.rs:61] indeksi = 6 [input/code.rs:61] indeksi = 1 [input/code.rs:61] indeksi = 2 [input/code.rs:61] indeksi = 3 [input/code.rs:61] indeksi = 4 [input/code.rs:61] indeksi = 5 [input/code.rs:61] indeksi = 1 [input/c...
