| Task: | Hypyt |
| Sender: | Lytsky |
| Submission time: | 2025-11-07 22:37:07 +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 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #3 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #4 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #5 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | WRONG ANSWER | 0.06 s | 2, 5 | details |
| #7 | WRONG ANSWER | 0.05 s | 2, 5 | details |
| #8 | WRONG ANSWER | 0.05 s | 2, 5 | details |
| #9 | WRONG ANSWER | 0.17 s | 3, 4, 5 | details |
| #10 | WRONG ANSWER | 0.17 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.17 s | 3, 4, 5 | details |
| #12 | WRONG ANSWER | 0.17 s | 4, 5 | details |
| #13 | WRONG ANSWER | 0.17 s | 4, 5 | details |
| #14 | WRONG ANSWER | 0.17 s | 4, 5 | details |
| #15 | WRONG ANSWER | 0.25 s | 5 | details |
| #16 | WRONG ANSWER | 0.24 s | 5 | details |
| #17 | WRONG ANSWER | 0.23 s | 5 | details |
| #18 | WRONG ANSWER | 0.23 s | 5 | details |
| #19 | ACCEPTED | 0.23 s | 5 | details |
| #20 | ACCEPTED | 0.23 s | 5 | details |
| #21 | ACCEPTED | 0.21 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.18 s | 5 | details |
| #25 | ACCEPTED | 0.18 s | 5 | details |
| #26 | ACCEPTED | 0.26 s | 5 | details |
| #27 | ACCEPTED | 0.22 s | 5 | details |
Code
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, q, ekay, ekax, tokay, tokax;
cin >> n >> m >> q;
string row;
vector<int> nodesInColumns[m];
vector<int> nodesInRows[n];
vector<int> col_dists[m], row_dists[n];
string answers;
string grid[n];
for (int index = 0; index < m; index++) {
vector<int> s(m, 1e9);
col_dists[index] = s;
}
for (int index = 0; index < n; index++) {
cin >> row;
grid[index] = row;
for (int col = 0; col < m; col++) {
if (grid[index][col] == '.') {
nodesInColumns[col].push_back(index);
nodesInRows[index].push_back(col);
}
}
vector<int> s(n, 1e9);
row_dists[index] = s;
}
for (int index = 0; index < m; index++) {
for (int j = 0; j < (int) nodesInColumns[index].size(); j++) {
for (int i = j; i < (int) nodesInColumns[index].size(); i++) {
if (nodesInColumns[index][j] < nodesInColumns[index][i]) {
if (row_dists[nodesInColumns[index][j]][nodesInColumns[index][i]] != 1) {
pair<vector<int>,vector<int>> p = {{nodesInColumns[index][i]}, {nodesInColumns[index][j]}};
row_dists[nodesInColumns[index][j]][nodesInColumns[index][i]] = 1;
}
} else if (nodesInColumns[index][j] == nodesInColumns[index][i]) {
row_dists[nodesInColumns[index][j]][nodesInColumns[index][i]] = 0;
}
}
}
}
for (int index = 0; index < n; index++) {
for (int j = 0; j < (int) nodesInRows[index].size(); j++) {
for (int i = j; i < (int) nodesInRows[index].size(); i++) {
if (nodesInRows[index][j] < nodesInRows[index][i]) {
if (col_dists[nodesInRows[index][j]][nodesInRows[index][i]] != 1) {
pair<vector<int>,vector<int>> p = {{nodesInRows[index][i]}, {nodesInRows[index][j]}};
col_dists[nodesInRows[index][j]][nodesInRows[index][i]] = 1;
}
} else if (nodesInRows[index][j] == nodesInRows[index][i]) {
col_dists[nodesInRows[index][j]][nodesInRows[index][i]] = 0;
}
}
}
}
for (int k = 0; k < n; k++) {
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
row_dists[i][j] = min(row_dists[i][j], row_dists[min(i,k)][max(i,k)] + row_dists[min(k,j)][max(k,j)]);
}
}
}
for (int k = 0; k < m; k++) {
for (int i = 0; i < m; i++) {
for (int j = i+1; j < m; j++) {
col_dists[i][j] = min(col_dists[i][j], col_dists[min(i,k)][max(i,k)] + col_dists[min(k,j)][max(k,j)]);
}
}
}
for (int index = 0; index < q; index++) {
cin >> ekay >> ekax >> tokay >> tokax;
int y1, y2, x1, x2;
if (ekay < tokay) {
y1 = ekay;
y2 = tokay;
} else {
y1 = tokay;
y2 = ekay;
}
if (ekax < tokax) {
x1 = ekax;
x2 = tokax;
} else {
x1 = tokax;
x2 = ekax;
}
if (y1 == y2 && x1 == x2) answers += "0\n";
else if (y1 == y2 || x1 == x2) answers += "1\n";
else {
if (col_dists[x1-1][x2-1] >= 1e9 || row_dists[y1-1][y2-1] >= 1e9) {
answers += "-1\n";
}
else {
answers += to_string(row_dists[y1-1][y2-1] + col_dists[x1-1][x2-1]) + "\n";
}
}
}
printf("%s", answers.c_str());
}
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: WRONG ANSWER
| input |
|---|
| 10 10 10 *...***.** *****.*... **..**.**. ..**.**.*. ... |
| correct output |
|---|
| 1 2 2 1 2 ... |
| user output |
|---|
| 1 2 2 1 2 ... |
Feedback: Incorrect character on line 8 col 1: expected "3", got "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: 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 2 2 2 2 ... |
Feedback: Incorrect character on line 2 col 1: expected "3", got "2"
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 2 ... |
Feedback: Incorrect character on line 5 col 1: expected "3", got "2"
Test 8
Group: 2, 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Feedback: Incorrect character on line 2 col 1: expected "3", got "2"
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 32 col 1: expected "3", got "2"
Test 10
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 **.**..*.*.*.******....****.*.... |
| correct output |
|---|
| 2 1 3 2 2 ... |
| user output |
|---|
| 2 1 2 2 2 ... |
Feedback: Incorrect character on line 3 col 1: expected "3", got "2"
Test 11
Group: 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 2 2 2 3 3 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "2"
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 30 col 1: expected "3", got "2"
Test 13
Group: 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 80 80 200000 .***.*..*.***..*****....**...*... |
| correct output |
|---|
| 3 2 2 3 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "2"
Test 14
Group: 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 80 80 200000 *******.*****.*..*..****...***... |
| correct output |
|---|
| 2 3 1 2 2 ... |
| user output |
|---|
| 2 2 1 2 2 ... |
Feedback: Incorrect character on line 2 col 1: expected "3", got "2"
Test 15
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *....*..*..*..**..*.........**... |
| correct output |
|---|
| 3 2 2 2 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "2"
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 "2"
Test 17
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *..*.*****.*********.****.****... |
| correct output |
|---|
| 3 3 2 2 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "2"
Test 18
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *********.**********.******.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "2"
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 ... |
