| Task: | Hypyt |
| Sender: | rottis |
| Submission time: | 2025-10-30 00:33:05 +0200 |
| Language: | C++ (C++17) |
| 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 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #5 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | ACCEPTED | 0.01 s | 2, 5 | details |
| #7 | ACCEPTED | 0.01 s | 2, 5 | details |
| #8 | ACCEPTED | 0.01 s | 2, 5 | details |
| #9 | ACCEPTED | 0.63 s | 3, 4, 5 | details |
| #10 | ACCEPTED | 0.75 s | 3, 4, 5 | details |
| #11 | ACCEPTED | 0.81 s | 3, 4, 5 | details |
| #12 | ACCEPTED | 0.73 s | 4, 5 | details |
| #13 | ACCEPTED | 0.96 s | 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.43 s | 5 | details |
| #25 | ACCEPTED | 0.43 s | 5 | details |
| #26 | ACCEPTED | 0.66 s | 5 | details |
| #27 | ACCEPTED | 0.46 s | 5 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
53 | for (int i = 0; i < query_count; i++) {
| ~~^~~~~~~~~~~~~Code
#include <iostream>
#include <unordered_map>
#include <string.h> // memset
#include <vector>
typedef unsigned char uchar;
// row/column
class Row {
public:
std::vector<uchar> connected_columns;
Row() {}
void connect_with(uchar other_idx) {
connected_columns.push_back(other_idx);
}
};
unsigned short height, width;
unsigned int query_count;
int main() {
Row rows[250];
Row columns[250];
std::cin >> height >> width >> query_count;
for (int i = 0; i < width; i++) {
columns[i] = Row();
}
for (int i = 0; i < height; i++) {
Row row = Row();
// <------
char buf[251];
std::cin >> buf;
for (int j = 0; j < width; j++) {
if (buf[j] == '.') {
row.connect_with(j);
columns[j].connect_with(i);
//std::cout << "Connect row idx " << i << " to column idx " << j << std::endl;
}
}
rows[i] = row;
}
for (int i = 0; i < query_count; i++) {
bool available_rows[250], available_cols[250];
unsigned short start_y, start_x, end_y, end_x;
std::cin >> start_y >> start_x >> end_y >> end_x;
start_y--; start_x--; end_y--; end_x--;
if (start_x == end_x && start_y == end_y) {
std::cout << "0\n";
continue;
}
if (start_x == end_x || start_y == end_y) {
std::cout << "1\n";
continue;
}
memset(&available_rows, 0, 250);
memset(&available_cols, 0, 250);
bool just_added_rows[250];
bool just_added_cols[250];
available_cols[start_x] = true;
available_rows[start_y] = true;
memset(&just_added_rows, 0, 250);
memset(&just_added_cols, 0, 250);
just_added_cols[start_x] = true;
just_added_rows[start_y] = true;
for (int cost = 2;; cost++) {
bool rows_to_add[250];
bool cols_to_add[250];
memset(&rows_to_add, 0, 250);
memset(&cols_to_add, 0, 250);
// set to false when modifying rows_to_add and cols_to_add, if no modifications are made then break out with -1
bool no_solution = true;
for (uchar row_idx = 0; row_idx < 250; row_idx++) {
if (!just_added_rows[row_idx]) { continue; }
//std::cout << "Row " << (int) row_idx << std::endl;
just_added_rows[row_idx] = false;
Row row = rows[row_idx];
for (uchar col_idx : row.connected_columns) {
//std::cout << "Add col " << (int) col_idx << std::endl;
cols_to_add[col_idx] = true;
no_solution = false;
}
}
for (uchar col_idx = 0; col_idx < 250; col_idx++) {
if (!just_added_cols[col_idx]) { continue; }
//std::cout << "Col " << (int) col_idx << std::endl;
just_added_cols[col_idx] = false;
Row col = columns[col_idx];
for (uchar row_idx : col.connected_columns) {
//std::cout << "Add row " << (int) row_idx << std::endl;
rows_to_add[row_idx] = true;
no_solution = false;
}
}
if (no_solution) { std::cout << -1 << '\n'; goto complete; }
if (rows_to_add[end_y] || cols_to_add[end_x]) { std::cout << cost << '\n'; goto complete; }
for (uchar idx = 0; idx < 250; idx++) {
if (rows_to_add[idx]) {
rows_to_add[idx] = false;
if (!available_rows[idx]) {
available_rows[idx] = true;
just_added_rows[idx] = true;
}
//if (idx == end_y) { std::cout << cost << '\n'; goto complete; }
}
if (cols_to_add[idx]) {
cols_to_add[idx] = false;
if (!available_cols[idx]) {
available_rows[idx] = true;
just_added_cols[idx] = true;
}
//if (idx == end_x) { std::cout << cost << '\n'; goto complete; }
}
}
}
complete:
continue;
}
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: 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: ACCEPTED
| input |
|---|
| 10 10 10 ***.*.**** ********** *.******** .*.***.**. ... |
| correct output |
|---|
| 3 4 2 3 4 ... |
| user output |
|---|
| 3 4 2 3 4 ... |
Test 5
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 1 .****.**** **.**..*** ********** *******..* ... |
| correct output |
|---|
| 7 |
| user output |
|---|
| -1 |
Feedback: Incorrect character on line 1 col 1: expected "7", got "-1"
Test 6
Group: 2, 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 250 .*...*.....*******..**...*....... |
| correct output |
|---|
| 2 3 3 2 2 ... |
| user output |
|---|
| 2 3 3 2 2 ... |
Test 7
Group: 2, 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| 2 2 2 2 3 ... |
Test 8
Group: 2, 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| 2 3 3 3 3 ... |
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: ACCEPTED
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 3 3 3 3 3 ... |
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: 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: 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 ... |
