| Task: | Hypyt |
| Sender: | asonnine |
| Submission time: | 2025-10-31 14:22:28 +0200 |
| Language: | Rust (2021) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | TIME LIMIT EXCEEDED | 0 |
| #2 | TIME LIMIT EXCEEDED | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| #4 | TIME LIMIT EXCEEDED | 0 |
| #5 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #2 | TIME LIMIT EXCEEDED | -- | 1, 2, 3, 4, 5 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 1, 2, 3, 4, 5 | details |
| #4 | TIME LIMIT EXCEEDED | -- | 1, 2, 3, 4, 5 | details |
| #5 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | TIME LIMIT EXCEEDED | -- | 2, 5 | details |
| #7 | TIME LIMIT EXCEEDED | -- | 2, 5 | details |
| #8 | TIME LIMIT EXCEEDED | -- | 2, 5 | details |
| #9 | TIME LIMIT EXCEEDED | -- | 3, 4, 5 | details |
| #10 | TIME LIMIT EXCEEDED | -- | 3, 4, 5 | details |
| #11 | TIME LIMIT EXCEEDED | -- | 3, 4, 5 | details |
| #12 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
| #13 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
| #14 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
| #15 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #16 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #17 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #18 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #19 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #20 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #21 | TIME LIMIT EXCEEDED | -- | 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.44 s | 5 | details |
| #25 | ACCEPTED | 0.33 s | 5 | details |
| #26 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #27 | ACCEPTED | 0.33 s | 5 | details |
Code
use std::{io, usize, vec};
#[derive(Debug, Clone)]
struct Row {
connections: Vec<usize>,
}
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> = vec![
Row {
connections: Vec::new()
};
n
];
for row in 0..n {
for column in 0..m {
if map[row][column] {
for rowi in 0..n {
if map[rowi][column] {
rows[row].connections.push(rowi);
}
}
}
}
}
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();
(
iter.next().unwrap().parse().unwrap(),
iter.next().unwrap().parse().unwrap(),
iter.next().unwrap().parse().unwrap(),
iter.next().unwrap().parse().unwrap(),
)
};
queries.push(((x1 - 1, y1 - 1), (x2 - 1, y2 - 1)));
}
let rows = rows;
let queries = queries;
dbg!(&rows);
for query in queries {
println!("{}", process_query(&rows, &map, query));
}
}
// NOTE: Needs to be O(n+m)
fn process_query(
map_rows: &Vec<Row>,
map: &Vec<Vec<bool>>,
query: ((usize, usize), (usize, usize)),
) -> i32 {
let mut steps = 1;
let rows = map_rows.len();
let mut used_rows = vec![false; rows];
if query.0 == query.1 {
return 0;
} else if query.0.0 == query.1.0 || query.0.1 == query.1.1 {
return 1;
}
let mut process_rows: Vec<usize> = Vec::new();
process_rows.push(query.0.1);
for row in 0..rows {
if map[row][query.0.0] {
process_rows.push(row);
used_rows[row] = true;
}
}
steps += 2;
let mut can_continue = false;
loop {
let mut new_process_rows: Vec<usize> = Vec::new();
for row in &process_rows {
for rowi in &map_rows[*row].connections {
if !used_rows[*rowi] {
used_rows[*rowi] = true;
new_process_rows.push(*rowi);
can_continue = true;
if *rowi == query.1.1 {
if map[*row][query.1.0] {
return steps + 1;
} else {
return steps;
}
}
}
}
}
if !can_continue {
return -1;
}
process_rows = new_process_rows;
}
}
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 |
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
0,
0,
1,
3,
],
},
Row {
connections: [
1,
3,
0,
1,
3,
1,
],
},
Row {
connections: [
2,
],
},
Row {
connections: [
1,
3,
0,
1,
3,
3,
],
},
]Test 2
Group: 1, 2, 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 10 10 10 .......... .....*.... ........*. *.*....*.. ... |
| correct output |
|---|
| 1 2 1 2 2 ... |
| user output |
|---|
| (empty) |
Test 3
Group: 1, 2, 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 10 10 10 *...***.** *****.*... **..**.**. ..**.**.*. ... |
| correct output |
|---|
| 1 2 2 1 2 ... |
| user output |
|---|
| (empty) |
Test 4
Group: 1, 2, 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 10 10 10 ***.*.**** ********** *.******** .*.***.**. ... |
| correct output |
|---|
| 3 4 2 3 4 ... |
| user output |
|---|
| (empty) |
Test 5
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 1 .****.**** **.**..*** ********** *******..* ... |
| correct output |
|---|
| 7 |
| user output |
|---|
| 3 |
Feedback: Incorrect character on line 1 col 1: expected "7", got "3"
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
0,
5,
0,
1,
8,
],
},
Row {
connections: [
1,
0,
1,
8,
1,
9,
],
},
Row {
connections: [],
},
Row {
connections: [
3,
5,
6,
3,
],
},
Row {
connections: [],
},
Row {
connections: [
0,
5,
3,
5,
6,
],
},
Row {
connections: [
6,
3,
5,
6,
],
},
Row {
connections: [],
},
Row {
connections: [
0,
1,
8,
],
},
Row {
connections: [
9,
1,
9,
],
},
]Test 6
Group: 2, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 250 .*...*.....*******..**...*....... |
| correct output |
|---|
| 2 3 3 2 2 ... |
| user output |
|---|
| (empty) |
Test 7
Group: 2, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| (empty) |
Test 8
Group: 2, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Test 9
Group: 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 40 40 200000 ...*.**.*..*.............*.*..... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 10
Group: 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 40 40 200000 **.**..*.*.*.******....****.*.... |
| correct output |
|---|
| 2 1 3 2 2 ... |
| user output |
|---|
| (empty) |
Test 11
Group: 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Test 12
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80 80 200000 *....**.***..****...*.....*...... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 13
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80 80 200000 .***.*..*.***..*****....**...*... |
| correct output |
|---|
| 3 2 2 3 2 ... |
| user output |
|---|
| (empty) |
Test 14
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80 80 200000 *******.*****.*..*..****...***... |
| correct output |
|---|
| 2 3 1 2 2 ... |
| user output |
|---|
| (empty) |
Test 15
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 *....*..*..*..**..*.........**... |
| correct output |
|---|
| 3 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 16
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 ..*....*..*......*.**.*.*..***... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 17
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 *..*.*****.*********.****.****... |
| correct output |
|---|
| 3 3 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 18
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 *********.**********.******.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Test 19
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| (empty) |
Test 20
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 ..****************************... |
| correct output |
|---|
| 57 155 38 65 98 ... |
| user output |
|---|
| (empty) |
Test 21
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 498 498 498 498 498 ... |
| user output |
|---|
| (empty) |
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 ... |
Error:
[input/code.rs:62] &rows = [
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [
2,
5,
9,
],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [
2,
5,
9,
],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [
2,
5,
9,
],
},
]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 ... |
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
},
]Test 24
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 1 200000 * . * . ... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 1 1 1 1 1 ... |
Error:
[input/code.rs:62] &rows = [
Row {
connections: [],
},
Row {
connections: [
1,
3,
4,
7,
9,
13,
14,
17,
18,
22,
25,
30,
31,
32,
34,
35,
36,
41,
42,
43,
45,
46,
47,
48,
50,
52,
57,
61,
64,
67,
68,
69,
70,
71,
72,
75,
76,
77,
78,
81,
83,
84,
85,
86,
87,
88,
91,
92,
93,
94,
96,
97,
98,
100,
103,
106,...Test 25
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 1 250 200000 *.*.*...*.*.**.***..**.*.*..**... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 1 1 1 1 1 ... |
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,...Test 26
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 ................................. |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 27
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 ******************************... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| 0 0 0 0 0 ... |
Error:
[input/code.rs:62] &rows = [
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
R...