| Task: | Hypyt |
| Sender: | asonnine |
| Submission time: | 2025-11-09 11:10:37 +0200 |
| Language: | Rust (2021) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| #4 | WRONG ANSWER | 0 |
| #5 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #2 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #3 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #4 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #5 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | RUNTIME ERROR | 0.00 s | 2, 5 | details |
| #7 | RUNTIME ERROR | 0.00 s | 2, 5 | details |
| #8 | RUNTIME ERROR | 0.00 s | 2, 5 | details |
| #9 | ACCEPTED | 0.32 s | 3, 4, 5 | details |
| #10 | ACCEPTED | 0.32 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.33 s | 3, 4, 5 | details |
| #12 | ACCEPTED | 0.32 s | 4, 5 | details |
| #13 | ACCEPTED | 0.32 s | 4, 5 | details |
| #14 | WRONG ANSWER | 0.32 s | 4, 5 | details |
| #15 | RUNTIME ERROR | 0.00 s | 5 | details |
| #16 | RUNTIME ERROR | 0.00 s | 5 | details |
| #17 | RUNTIME ERROR | 0.00 s | 5 | details |
| #18 | RUNTIME ERROR | 0.00 s | 5 | details |
| #19 | RUNTIME ERROR | 0.00 s | 5 | details |
| #20 | RUNTIME ERROR | 0.00 s | 5 | details |
| #21 | RUNTIME ERROR | 0.00 s | 5 | details |
| #22 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #23 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #24 | ACCEPTED | 0.33 s | 5 | details |
| #25 | RUNTIME ERROR | 0.00 s | 5 | details |
| #26 | RUNTIME ERROR | 0.00 s | 5 | details |
| #27 | RUNTIME ERROR | 0.00 s | 5 | details |
Compiler report
warning: unused variable: `m`
--> input/code.rs:91:13
|
91 | let (n, m, q): (usize, usize, usize) = {
| ^ help: if this is intentional, prefix it with an underscore: `_m`
|
= note: `#[warn(unused_variables)]` on by default
warning: 1 warning emittedCode
use std::{io, ops::BitAnd};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct PathNode {
jump_target: usize,
jump_column: usize,
path_length: usize,
}
#[derive(Debug, Clone, Eq)]
struct Row {
first_half: u128,
second_half: u128,
pub paths: Vec<Option<PathNode>>, // (target row, jump column, path length)
}
impl PartialEq for Row {
fn eq(&self, other: &Self) -> bool {
self.first_half == other.first_half && self.second_half == other.second_half
}
}
impl TryFrom<&Vec<bool>> for Row {
type Error = ();
fn try_from(value: &Vec<bool>) -> Result<Self, Self::Error> {
match value.len() {
len if len <= 128 => {
let mut first_half = [false; 128];
first_half[..len].copy_from_slice(&value);
let first_half = u128_from_bits(first_half);
let second_half = 0u128;
Ok(Row {
first_half,
second_half,
paths: Vec::new(),
})
}
len if len <= 256 => {
let mut first_half = [false; 128];
let mut second_half = [false; 128];
first_half.copy_from_slice(&value[..128]);
second_half.copy_from_slice(&value[128..]);
let first_half = u128_from_bits(first_half);
let second_half = u128_from_bits(second_half);
Ok(Row {
first_half,
second_half,
paths: Vec::new(),
})
}
_ => Err(()),
}
}
}
impl BitAnd for &Row {
type Output = Row;
fn bitand(self, rhs: Self) -> Self::Output {
Row {
first_half: self.first_half & rhs.first_half,
second_half: self.second_half & rhs.second_half,
paths: Vec::new(),
}
}
}
impl Row {
fn is_zero(&self) -> bool {
self.first_half == 0 && self.second_half == 0
}
fn trailing_zeros(&self) -> u32 {
let out = self.second_half.trailing_zeros();
if out == 128 {
out + self.first_half.trailing_zeros()
} else {
out
}
}
}
fn u128_from_bits(value: [bool; 128]) -> u128 {
let mut out = 0u128;
for i in 0..128 {
out += (value[i] as u128) << 127 - i;
}
out
}
fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let (n, m, q): (usize, usize, usize) = {
let mut iter = input.split_whitespace();
(
iter.next().unwrap().parse().unwrap(),
iter.next().unwrap().parse().unwrap(),
iter.next().unwrap().parse().unwrap(),
)
};
let mut map: Vec<Vec<bool>> = Vec::new();
for _ in 0..n {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
map.push(input.trim().chars().map(|x| x == '.').collect());
}
let mut rows: Vec<Row> = map.iter().map(|row| row.try_into().unwrap()).collect();
for target_row in 0..n {
for row in rows.iter_mut() {
row.paths.push(None);
}
for row in 0..n {
let intersection = &rows[row] & &rows[target_row];
if !intersection.is_zero() {
rows[row].paths[target_row] = Some(PathNode {
jump_target: target_row,
jump_column: (255 - intersection.trailing_zeros()) as usize,
path_length: 1,
});
}
}
for step in 1..n {
let mut can_continue = false;
for step_target_row in 0..n {
if rows[step_target_row].paths[target_row].is_some_and(|x| x.path_length == step) {
for row in 0..n {
if rows[row].paths[target_row].is_none() {
let intersection = &rows[row] & &rows[step_target_row];
if !intersection.is_zero() {
rows[row].paths[target_row] = Some(PathNode {
jump_target: step_target_row,
jump_column: (255 - intersection.trailing_zeros()) as usize,
path_length: step + 1,
});
can_continue = true;
}
}
}
}
}
if !can_continue {
break;
}
}
}
let mut queries: Vec<((usize, usize), (usize, usize))> = Vec::new();
for _ in 0..q {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let (y1, x1, y2, x2): (usize, usize, usize, usize) = {
let mut iter = input.split_whitespace();
let y1 = iter.next().unwrap().parse::<usize>().unwrap() - 1;
let x1 = iter.next().unwrap().parse::<usize>().unwrap() - 1;
let y2 = iter.next().unwrap().parse::<usize>().unwrap() - 1;
let x2 = iter.next().unwrap().parse::<usize>().unwrap() - 1;
(y1, x1, y2, x2)
};
queries.push(((x1, y1), (x2, y2)));
}
let rows = rows;
let queries = queries;
let map = map;
for query in queries {
println!("{}", process_query(&rows, &map, query));
}
}
fn process_query(
rows: &Vec<Row>,
map: &Vec<Vec<bool>>,
query: ((usize, usize), (usize, usize)),
) -> i32 {
if query.0 == query.1 {
return 0;
}
if query.0.0 == query.1.0 || query.0.1 == query.1.1 {
return 1;
}
if rows[query.0.1].paths[query.1.1].is_none() {
return -1;
}
if rows[query.0.1].paths[query.1.1].unwrap().jump_target == query.1.1
&& (map[query.0.1][query.1.0] || map[query.1.1][query.0.0])
{
return 2;
}
let mut steps = 0;
if !map[rows[query.0.1].paths[query.1.1].unwrap().jump_target][query.0.0] {
steps += 1;
}
let mut current_row = query.0.1;
while rows[current_row].paths[query.1.1].unwrap().jump_target != query.1.1 {
current_row = rows[current_row].paths[query.1.1].unwrap().jump_target;
steps += 2;
}
steps += 1;
if !map[current_row][query.1.0] {
steps += 1;
}
steps
}
Test details
Test 1 (public)
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 4 6 5 .*.*** *...** *****. *..*.* ... |
| correct output |
|---|
| 1 0 3 3 -1 |
| user output |
|---|
| 1 0 3 3 -1 |
Test 2
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 10 10 10 .......... .....*.... ........*. *.*....*.. ... |
| correct output |
|---|
| 1 2 1 2 2 ... |
| user output |
|---|
| 1 2 1 2 2 ... |
Test 3
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 10 10 10 *...***.** *****.*... **..**.**. ..**.**.*. ... |
| correct output |
|---|
| 1 2 2 1 2 ... |
| user output |
|---|
| 1 2 2 1 2 ... |
Test 4
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 10 ***.*.**** ********** *.******** .*.***.**. ... |
| correct output |
|---|
| 3 4 2 3 4 ... |
| user output |
|---|
| 3 4 2 3 4 ... |
Feedback: Incorrect character on line 8 col 1: expected "3", got "5"
Test 5
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 10 10 1 .****.**** **.**..*** ********** *******..* ... |
| correct output |
|---|
| 7 |
| user output |
|---|
| 7 |
Test 6
Group: 2, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 250 .*...*.....*******..**...*....... |
| correct output |
|---|
| 2 3 3 2 2 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 7
Group: 2, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 8
Group: 2, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 9
Group: 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 40 40 200000 ...*.**.*..*.............*.*..... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Test 10
Group: 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 40 40 200000 **.**..*.*.*.******....****.*.... |
| correct output |
|---|
| 2 1 3 2 2 ... |
| user output |
|---|
| 2 1 3 2 2 ... |
Test 11
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 3 3 3 3 4 ... |
Feedback: Incorrect character on line 5 col 1: expected "3", got "4"
Test 12
Group: 4, 5
Verdict: ACCEPTED
| input |
|---|
| 80 80 200000 *....**.***..****...*.....*...... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Test 13
Group: 4, 5
Verdict: ACCEPTED
| input |
|---|
| 80 80 200000 .***.*..*.***..*****....**...*... |
| correct output |
|---|
| 3 2 2 3 2 ... |
| user output |
|---|
| 3 2 2 3 2 ... |
Test 14
Group: 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 80 80 200000 *******.*****.*..*..****...***... |
| correct output |
|---|
| 2 3 1 2 2 ... |
| user output |
|---|
| 2 3 1 2 2 ... |
Feedback: Incorrect character on line 147 col 1: expected "3", got "5"
Test 15
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 *....*..*..*..**..*.........**... |
| correct output |
|---|
| 3 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 16
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 ..*....*..*......*.**.*.*..***... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 17
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 *..*.*****.*********.****.****... |
| correct output |
|---|
| 3 3 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 18
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 *********.**********.******.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 19
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 20
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 ..****************************... |
| correct output |
|---|
| 57 155 38 65 98 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 21
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 498 498 498 498 498 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 22
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 10 1 10 * * . * ... |
| correct output |
|---|
| 0 1 1 0 0 ... |
| user output |
|---|
| 0 1 1 0 0 ... |
Test 23
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 1 10 10 ........*. 1 7 1 10 1 4 1 7 1 5 1 1 ... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 1 1 1 1 1 ... |
Test 24
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 1 200000 * . * . ... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 1 1 1 1 1 ... |
Test 25
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 1 250 200000 *.*.*...*.*.**.***..**.*.*..**... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 26
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 ................................. |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Test 27
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 ******************************... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Error:
thread 'main' panicked at input/code.rs:42:29: source slice length (122) does not match destination slice length (128) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
