| Task: | Hypyt |
| Sender: | asonnine |
| Submission time: | 2025-11-01 10:30:38 +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 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #3 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #4 | TIME LIMIT EXCEEDED | -- | 1, 2, 3, 4, 5 | details |
| #5 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | TIME LIMIT EXCEEDED | -- | 2, 5 | details |
| #7 | WRONG ANSWER | 0.85 s | 2, 5 | details |
| #8 | WRONG ANSWER | 0.55 s | 2, 5 | details |
| #9 | WRONG ANSWER | 0.56 s | 3, 4, 5 | details |
| #10 | WRONG ANSWER | 0.70 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.70 s | 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.32 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.contains(&rowi) && row != rowi {
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));
}
}
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();
let mut advantages = vec![false; rows];
advantages[query.0.1] = true;
for row in 0..rows {
if map[row][query.0.0] {
process_rows.push(row);
used_rows[row] = true;
}
}
let mut can_continue = false;
loop {
if used_rows[query.1.1] {
return steps + 1;
}
let mut new_process_rows: Vec<usize> = Vec::new();
let mut new_advantages = vec![false; rows];
let mut lowest_score = -1;
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 advantages[row] {
new_advantages[*rowi] = true;
}
if *rowi == query.1.1 {
if advantages[row] {
if map[row][query.1.0] {
return steps + 1;
} else {
return steps + 2;
}
} else {
if map[row][query.1.0] {
lowest_score = steps + 2;
} else {
lowest_score = steps + 3;
}
}
}
} else if advantages[row]
&& !new_advantages[*rowi]
&& new_process_rows.contains(rowi)
{
new_advantages[*rowi] = true;
}
}
}
if lowest_score != -1 {
return lowest_score;
}
if !can_continue {
return -1;
}
process_rows = new_process_rows;
advantages = new_advantages;
steps += 2;
}
}
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: [
1,
3,
],
},
Row {
connections: [
3,
0,
],
},
Row {
connections: [],
},
Row {
connections: [
1,
0,
],
},
]Test 2
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 10 .......... .....*.... ........*. *.*....*.. ... |
| correct output |
|---|
| 1 2 1 2 2 ... |
| user output |
|---|
| 1 2 1 2 3 ... |
Feedback: Incorrect character on line 5 col 1: expected "2", got "3"
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
1,
2,
4,
5,
6,
7,
8,
9,
3,
],
},
Row {
connections: [
0,
2,
4,
5,
6,
7,
8,
9,
3,
],
},
Row {
connections: [
0,
1,
4,
5,
6,
7,
8,
9,
3,
],
},
Row {
connections: [
0,
1,
2,
4,
5,
8,
6,
9,
7,
],
},
Row {
connections: [
0,
1,
2,
5,
6,
7,
8,
9,
3,
],
},
Row {
connections: [...Test 3
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 10 *...***.** *****.*... **..**.**. ..**.**.*. ... |
| correct output |
|---|
| 1 2 2 1 2 ... |
| user output |
|---|
| 1 4 3 1 2 ... |
Feedback: Incorrect character on line 2 col 1: expected "2", got "4"
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
3,
4,
5,
6,
8,
2,
7,
9,
1,
],
},
Row {
connections: [
9,
0,
3,
4,
5,
6,
7,
2,
],
},
Row {
connections: [
0,
4,
7,
8,
9,
5,
6,
1,
3,
],
},
Row {
connections: [
4,
5,
8,
0,
6,
7,
1,
2,
9,
],
},
Row {
connections: [
3,
5,
8,
0,
6,
2,
7,
9,
1,
],
},
Row {
connections: [
3,...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: ACCEPTED
| input |
|---|
| 10 10 1 .****.**** **.**..*** ********** *******..* ... |
| correct output |
|---|
| 7 |
| user output |
|---|
| 7 |
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
5,
1,
8,
],
},
Row {
connections: [
0,
8,
9,
],
},
Row {
connections: [],
},
Row {
connections: [
5,
6,
],
},
Row {
connections: [],
},
Row {
connections: [
0,
3,
6,
],
},
Row {
connections: [
3,
5,
],
},
Row {
connections: [],
},
Row {
connections: [
0,
1,
],
},
Row {
connections: [
1,
],
},
]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: WRONG ANSWER
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| 3 4 2 2 3 ... |
Feedback: Incorrect character on line 1 col 1: expected "2", got "3"
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
2,
3,
4,
8,
9,
11,
12,
15,
16,
20,
21,
22,
23,
26,
28,
29,
32,
36,
37,
41,
45,
46,
47,
50,
52,
53,
54,
62,
64,
67,
68,
70,
72,
74,
75,
77,
78,
79,
80,
84,
88,
93,
96,
97,
98,
99,
102,
105,
106,
107,
108,
109,
110,
111,
112,
114,
116,
120,...Test 8
Group: 2, 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| 2 4 3 4 3 ... |
Feedback: Incorrect character on line 2 col 1: expected "3", got "4"
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
4,
18,
22,
25,
26,
27,
31,
34,
39,
45,
55,
59,
60,
71,
76,
86,
88,
90,
94,
99,
103,
107,
108,
118,
121,
123,
126,
127,
135,
144,
150,
154,
157,
163,
168,
174,
178,
180,
181,
184,
186,
189,
194,
196,
202,
204,
209,
217,
220,
223,
229,
236,
237,
246,
247,
2,...Test 9
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 ...*.**.*..*.............*.*..... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 3 2 3 2 ... |
Feedback: Incorrect character on line 2 col 1: expected "2", got "3"
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
2,
3,
4,
5,
6,
7,
8,
9,
10,
12,
13,
14,
15,
16,
18,
19,
22,
23,
24,
25,
26,
27,
28,
29,
30,
32,
33,
34,
35,
36,
37,
39,
1,
11,
20,
31,
21,
38,
17,
],
},
Row {
connections: [
0,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
13,
15,
16,
18,
19,
20,...Test 10
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 **.**..*.*.*.******....****.*.... |
| correct output |
|---|
| 2 1 3 2 2 ... |
| user output |
|---|
| 2 1 4 2 2 ... |
Feedback: Incorrect character on line 3 col 1: expected "3", got "4"
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
1,
3,
6,
8,
14,
16,
18,
21,
22,
24,
27,
28,
29,
31,
33,
35,
36,
37,
39,
4,
9,
11,
17,
20,
23,
26,
30,
34,
10,
12,
13,
15,
19,
25,
32,
38,
5,
7,
2,
],
},
Row {
connections: [
3,
7,
9,
10,
12,
13,
15,
17,
19,
20,
21,
24,
25,
26,
27,
30,
31,...Test 11
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 4 4 4 4 4 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "4"
Error:
[input/code.rs:62] &rows = [
Row {
connections: [
4,
11,
18,
19,
36,
38,
1,
5,
13,
14,
16,
21,
22,
26,
34,
37,
2,
6,
7,
9,
17,
29,
35,
8,
12,
28,
32,
20,
27,
31,
3,
23,
25,
10,
15,
30,
],
},
Row {
connections: [
0,
5,
11,
13,
14,
16,
18,
21,
22,
26,
34,
36,
37,
9,
20,
27,
31,
32,
19,
25,...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: [
5,
9,
],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [
2,
9,
],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [],
},
Row {
connections: [
2,
5,
],
},
]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: [],
},
]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: [
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,
107,...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: [],
},
]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...