| Task: | Hypyt |
| Sender: | Lelleri |
| Submission time: | 2025-10-29 00:43:32 +0200 |
| Language: | C++ (C++11) |
| 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 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #5 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | WRONG ANSWER | 0.47 s | 2, 5 | details |
| #7 | WRONG ANSWER | 0.22 s | 2, 5 | details |
| #8 | WRONG ANSWER | 0.09 s | 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 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #25 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #26 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #27 | WRONG ANSWER | 0.29 s | 5 | details |
Compiler report
input/code.cpp: In function 'int bidirectional_bfs(int, int, Node, Node)':
input/code.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Node*>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(int c=0; c<current_start.connections.size(); c++){
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Node*>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int c=0; c<current_end.connections.size(); c++){
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp:44:13: warning: unused variable 'move_count' [-Wunused-variable]
44 | int move_count = q_end.front().second;
| ^~~~~~~~~~
input/code.cpp: In function 'std::vector<Node*> merge_without(std::vector<Node*>, std::vector<Node*>, Node)':
input/code.cpp:65:19: warning: co...Code
#include <bits/stdc++.h>
using namespace std;
struct Node{
int x;
int y;
vector<Node *> connections;
};
int bidirectional_bfs(int n, int m, Node start_node, Node end_node){
unordered_set<int> visited_start;
visited_start.insert(start_node.x + start_node.y*m);
unordered_set<int> visited_end;
visited_end.insert(end_node.x + end_node.y*m);
queue<pair<Node*, int>> q_start; // {Node, move_count}
queue<pair<Node*, int>> q_end; // {Node, move_count}
q_start.push({&start_node, 0});
q_end.push({&end_node, 0});
while (q_start.size() > 0 && q_end.size() > 0){
int start_move_count = q_start.front().second;
int end_move_count = q_end.front().second;
// Search start
Node current_start = *q_start.front().first;
q_start.pop();
for(int c=0; c<current_start.connections.size(); c++){
int v = (*current_start.connections[c]).x + (*current_start.connections[c]).y * m;
if(visited_start.find(v) == visited_start.end()){
q_start.push({current_start.connections[c], start_move_count+1});
visited_start.insert(v);
}
if(visited_end.find(v) != visited_end.end()){
return start_move_count + end_move_count + 1;
}
}
// Search end
Node current_end = *q_end.front().first;
int move_count = q_end.front().second;
q_end.pop();
for(int c=0; c<current_end.connections.size(); c++){
int v = (*current_end.connections[c]).x + (*current_end.connections[c]).y * m;
if(visited_end.find(v) == visited_end.end()){
q_end.push({current_end.connections[c], end_move_count+1});
visited_end.insert(v);
}
if(visited_start.find(v) != visited_start.end()){
return start_move_count + end_move_count;
}
}
}
return -1;
}
vector<Node*> merge_without(vector<Node*> list1, vector<Node*> list2, Node exclude){
vector<Node*> list3;
for(int i=0; i<list1.size(); i++){
if(exclude.x != (*list1[i]).x || exclude.y != (*list1[i]).y){
list3.push_back(list1[i]);
}
}
for(int i=0; i<list2.size(); i++){
if(exclude.x != (*list2[i]).x || exclude.y != (*list2[i]).y){
list3.push_back(list2[i]);
}
}
return list3;
}
int main() {
int n, m, q;
cin >> n >> m >> q;
vector<Node> nodes;
map<pair<int, int>, Node> node_map;
vector<vector<Node*>> rows;
vector<vector<Node*>> cols;
for(int i=0; i < n; i++){
for(int j=0; j < m; j++){
char val;
cin >> val;
if(val == '*') continue;
Node node = {j, i, {}};
nodes.push_back(node);
}
}
for(int i=0; i < n; i++){ rows.push_back({}); }
for(int j=0; j < m; j++){ cols.push_back({}); }
for(int k=0; k < nodes.size(); k++){ rows[nodes[k].y].push_back(&nodes[k]); }
for(int k=0; k < nodes.size(); k++){ cols[nodes[k].x].push_back(&nodes[k]); }
for(int k=0; k < nodes.size(); k++){
nodes[k].connections = merge_without(rows[nodes[k].y], cols[nodes[k].x], nodes[k]);
node_map[{nodes[k].x, nodes[k].y}] = nodes[k];
}
vector<int> results;
for(int i=0; i < q; i++){
int x1, y1, x2, y2;
cin >> y1 >> x1 >> y2 >> x2;
Node start_node = node_map[{x1-1, y1-1}];
Node end_node = node_map[{x2-1, y2-1}];
results.push_back(bidirectional_bfs(n, m, start_node, end_node));
}
for(int i=0; i<q; i++){
cout << results[i] << "\n";
}
return 0;
}
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: WRONG ANSWER
| input |
|---|
| 10 10 10 .......... .....*.... ........*. *.*....*.. ... |
| correct output |
|---|
| 1 2 1 2 2 ... |
| user output |
|---|
| 1 0 1 0 0 ... |
Feedback: Incorrect character on line 2 col 1: expected "2", got "0"
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 0 0 1 0 ... |
Feedback: Incorrect character on line 2 col 1: expected "2", got "0"
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 3 0 2 3 ... |
Feedback: Incorrect character on line 2 col 1: expected "4", got "3"
Test 5
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 1 .****.**** **.**..*** ********** *******..* ... |
| correct output |
|---|
| 7 |
| user output |
|---|
| 5 |
Feedback: Incorrect character on line 1 col 1: expected "7", got "5"
Test 6
Group: 2, 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 250 .*...*.....*******..**...*....... |
| correct output |
|---|
| 2 3 3 2 2 ... |
| user output |
|---|
| 0 3 3 0 0 ... |
Feedback: Incorrect character on line 1 col 1: expected "2", got "0"
Test 7
Group: 2, 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| 0 0 0 0 2 ... |
Feedback: Incorrect character on line 1 col 1: expected "2", got "0"
Test 8
Group: 2, 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| 0 2 2 3 2 ... |
Feedback: Incorrect character on line 1 col 1: expected "2", got "0"
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 ... |
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: TIME LIMIT EXCEEDED
| input |
|---|
| 250 1 200000 * . * . ... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| (empty) |
Test 25
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1 250 200000 *.*.*...*.*.**.***..**.*.*..**... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| (empty) |
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: WRONG ANSWER
| input |
|---|
| 250 250 200000 ******************************... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| -1 -1 -1 -1 -1 ... |
Feedback: Incorrect character on line 1 col 1: expected "0", got "-1"
