| Task: | Hypyt |
| Sender: | JuusoH |
| Submission time: | 2025-11-09 14:18:51 +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 | WRONG ANSWER | 0.07 s | 2, 5 | details |
| #7 | WRONG ANSWER | 0.06 s | 2, 5 | details |
| #8 | WRONG ANSWER | 0.04 s | 2, 5 | details |
| #9 | WRONG ANSWER | 0.32 s | 3, 4, 5 | details |
| #10 | WRONG ANSWER | 0.32 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.32 s | 3, 4, 5 | details |
| #12 | WRONG ANSWER | 0.32 s | 4, 5 | details |
| #13 | WRONG ANSWER | 0.33 s | 4, 5 | details |
| #14 | WRONG ANSWER | 0.32 s | 4, 5 | details |
| #15 | WRONG ANSWER | 0.40 s | 5 | details |
| #16 | WRONG ANSWER | 0.38 s | 5 | details |
| #17 | WRONG ANSWER | 0.37 s | 5 | details |
| #18 | WRONG ANSWER | 0.35 s | 5 | details |
| #19 | ACCEPTED | 0.33 s | 5 | details |
| #20 | ACCEPTED | 0.33 s | 5 | details |
| #21 | ACCEPTED | 0.32 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.32 s | 5 | details |
| #25 | ACCEPTED | 0.32 s | 5 | details |
| #26 | ACCEPTED | 0.41 s | 5 | details |
| #27 | ACCEPTED | 0.30 s | 5 | details |
Compiler report
warning: unused import: `std::time::*`
--> input/code.rs:3:5
|
3 | use std::time::*;
| ^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused variable: `l`
--> input/code.rs:26:13
|
26 | for l in 0..m {
| ^ help: if this is intentional, prefix it with an underscore: `_l`
|
= note: `#[warn(unused_variables)]` on by default
warning: unused variable: `l`
--> input/code.rs:93:13
|
93 | for l in 0..node_count {
| ^ help: if this is intentional, prefix it with an underscore: `_l`
warning: unused variable: `board`
--> input/code.rs:128:5
|
128 | board: &Vec<Vec<bool>>,
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_board`
warning: type alias `Pos` is never used
--> input/code.rs:4:6
|
4 | type Pos = (usize, usize);
| ^^^
|
= note: `#[warn(dead_code)]` on by default
warning: function `one_jump_gap` is never used
--> input/code.rs:170...Code
use std::collections::VecDeque;
use std::io::{self};
use std::time::*;
type Pos = (usize, usize);
fn main() {
//test_perf();
//from_file();
//return;
let mut input = String::new();
let stdin = io::stdin();
_ = stdin.read_line(&mut input);
let mut first_line = input.split_whitespace();
let n: usize = first_line.next().unwrap().parse().unwrap();
let m: usize = first_line.next().unwrap().parse().unwrap();
let q: usize = first_line.next().unwrap().parse().unwrap();
let mut board: Vec<Vec<bool>> = vec![];
for i in 0..n {
board.push(vec![]);
input.clear();
_ = stdin.read_line(&mut input);
let mut line = input.chars();
for l in 0..m {
board[i].push(line.next().unwrap() == '*');
}
}
//let mut tests: Vec<(usize, usize, usize, usize)> = vec![];
let distance_pairs = precomputations(&board, n, m);
for _ in 0..q {
input.clear();
_ = stdin.read_line(&mut input);
let mut line = input.split_whitespace();
let y1: usize = line.next().unwrap().parse().unwrap();
let x1: usize = line.next().unwrap().parse().unwrap();
let y2: usize = line.next().unwrap().parse().unwrap();
let x2: usize = line.next().unwrap().parse().unwrap();
//tests.push((y1 - 1, x1 - 1, y2 - 1, x2 - 1));
println!(
"{}",
process_test(&board, n, &distance_pairs, (y1 - 1, x1 - 1, y2 - 1, x2 - 1))
);
}
// test_once(
// &tests, &board, &row_safe, &col_safe, &mut cells, n, m, is_sparse,
// );
}
fn precomputations(board: &Vec<Vec<bool>>, n: usize, m: usize) -> Vec<Vec<i32>> {
let mut cols_in_row: Vec<Vec<usize>> = vec![];
cols_in_row.reserve(n);
let mut rows_in_col: Vec<Vec<usize>> = vec![];
rows_in_col.reserve(m);
for _ in 0..m {
rows_in_col.push(vec![]);
}
for i in 0..n {
let row = &board[i];
cols_in_row.push(vec![]);
for l in 0..m {
let cell = row[l];
if !cell {
cols_in_row[i].push(l);
rows_in_col[l].push(i);
}
}
}
let node_count = n + m;
let mut connections: Vec<Vec<usize>> = vec![];
for _ in 0..node_count {
connections.push(vec![]);
}
for i in 0..n {
for &l in &cols_in_row[i] {
let row_index = i;
let col_index = n + l;
connections[row_index].push(col_index);
connections[col_index].push(row_index);
}
}
let mut distance_pairs: Vec<Vec<i32>> = vec![];
for i in 0..node_count {
distance_pairs.push(vec![]);
for l in 0..node_count {
distance_pairs[i].push(-1);
}
}
let mut deque: VecDeque<usize> = VecDeque::new();
for s in 0..node_count {
if connections[s].is_empty() {
distance_pairs[s][s] = 0;
continue;
}
let dist_row = &mut distance_pairs[s];
dist_row[s] = 0;
deque.clear();
deque.push_back(s);
while deque.len() > 0 {
let u = deque.pop_back().unwrap();
let nu = dist_row[u] + 1;
for &v in &connections[u] {
if dist_row[v] == -1 {
dist_row[v] = nu;
deque.push_back(v);
}
}
}
}
distance_pairs
}
const START_MIN: i32 = 67i32.pow(5); //67
fn process_test(
board: &Vec<Vec<bool>>,
n: usize,
distance_pairs: &Vec<Vec<i32>>,
test: (usize, usize, usize, usize),
) -> i32 {
let a = (test.0, test.1);
let b = (test.2, test.3);
if a == b {
return 0;
}
/*if one_jump_gap(&a, &b) {
return 1;}
if two_jump_gap(board, &a, &b) {
return 2;
}*/
let start_row = a.0;
let end_row = b.0;
let start_col = n + a.1;
let end_col = n + b.1;
let mut smallest_distance = START_MIN;
let mut res_distances = vec![];
res_distances.push(distance_pairs[start_row][end_row]);
res_distances.push(distance_pairs[start_row][end_col]);
res_distances.push(distance_pairs[start_col][end_row]);
res_distances.push(distance_pairs[start_col][end_col]);
let mut found = false;
for dist in res_distances {
if dist != -1 {
smallest_distance = dist.min(smallest_distance);
found = true;
}
}
if !found { -1 } else { smallest_distance + 1 }
}
fn one_jump_gap(a: &Pos, b: &Pos) -> bool {
a.0 == b.0 || a.1 == b.1
}
fn two_jump_gap(board: &Vec<Vec<bool>>, a: &Pos, b: &Pos) -> bool {
!board[a.0][b.1] || !board[b.0][a.1]
}
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 6 ... |
Feedback: Incorrect character on line 5 col 1: expected "4", got "6"
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: WRONG ANSWER
| input |
|---|
| 250 250 250 .*...*.....*******..**...*....... |
| correct output |
|---|
| 2 3 3 2 2 ... |
| user output |
|---|
| 2 3 3 2 2 ... |
Feedback: Incorrect character on line 134 col 1: expected "3", got "5"
Test 7
Group: 2, 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| 2 2 2 2 3 ... |
Feedback: Incorrect character on line 7 col 1: expected "3", got "5"
Test 8
Group: 2, 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| 2 10 5 6 5 ... |
Feedback: Incorrect character on line 2 col 1: expected "3", got "10"
Test 9
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 ...*.**.*..*.............*.*..... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Feedback: Incorrect character on line 102 col 1: expected "3", got "4"
Test 10
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 **.**..*.*.*.******....****.*.... |
| correct output |
|---|
| 2 1 3 2 2 ... |
| user output |
|---|
| 2 1 3 2 2 ... |
Feedback: Incorrect character on line 18 col 1: expected "3", got "4"
Test 11
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 7 7 4 5 11 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "7"
Test 12
Group: 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 80 80 200000 *....**.***..****...*.....*...... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Feedback: Incorrect character on line 81 col 1: expected "3", got "5"
Test 13
Group: 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 80 80 200000 .***.*..*.***..*****....**...*... |
| correct output |
|---|
| 3 2 2 3 2 ... |
| user output |
|---|
| 3 2 2 3 2 ... |
Feedback: Incorrect character on line 20 col 1: expected "3", got "7"
Test 14
Group: 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 80 80 200000 *******.*****.*..*..****...***... |
| correct output |
|---|
| 2 3 1 2 2 ... |
| user output |
|---|
| 2 5 1 2 2 ... |
Feedback: Incorrect character on line 2 col 1: expected "3", got "5"
Test 15
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *....*..*..*..**..*.........**... |
| correct output |
|---|
| 3 2 2 2 2 ... |
| user output |
|---|
| 3 2 2 2 2 ... |
Feedback: Incorrect character on line 475 col 1: expected "3", got "5"
Test 16
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 ..*....*..*......*.**.*.*..***... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Feedback: Incorrect character on line 12 col 1: expected "3", got "5"
Test 17
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *..*.*****.*********.****.****... |
| correct output |
|---|
| 3 3 2 2 2 ... |
| user output |
|---|
| 10 3 2 2 2 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "10"
Test 18
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *********.**********.******.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 5 6 13 17 17 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "5"
Test 19
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| 104 422 145 93 65 ... |
Test 20
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 ..****************************... |
| correct output |
|---|
| 57 155 38 65 98 ... |
| user output |
|---|
| 57 155 38 65 98 ... |
Test 21
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 498 498 498 498 498 ... |
| user output |
|---|
| 498 498 498 498 498 ... |
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: ACCEPTED
| input |
|---|
| 1 250 200000 *.*.*...*.*.**.***..**.*.*..**... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 1 1 1 1 1 ... |
Test 26
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 ................................. |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Test 27
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 ******************************... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| 0 0 0 0 0 ... |
