| Task: | Hypyt |
| Sender: | Tmotomaster |
| Submission time: | 2025-11-07 22:47:56 +0200 |
| Language: | C++ (C++20) |
| 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 | WRONG ANSWER | 0.00 s | 1, 2, 3, 4, 5 | details |
| #5 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | ACCEPTED | 0.23 s | 2, 5 | details |
| #7 | ACCEPTED | 0.23 s | 2, 5 | details |
| #8 | ACCEPTED | 0.18 s | 2, 5 | details |
| #9 | ACCEPTED | 0.10 s | 3, 4, 5 | details |
| #10 | ACCEPTED | 0.10 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.10 s | 3, 4, 5 | details |
| #12 | ACCEPTED | 0.12 s | 4, 5 | details |
| #13 | ACCEPTED | 0.12 s | 4, 5 | details |
| #14 | WRONG ANSWER | 0.12 s | 4, 5 | details |
| #15 | ACCEPTED | 0.43 s | 5 | details |
| #16 | ACCEPTED | 0.46 s | 5 | details |
| #17 | ACCEPTED | 0.38 s | 5 | details |
| #18 | WRONG ANSWER | 0.33 s | 5 | details |
| #19 | ACCEPTED | 0.10 s | 5 | details |
| #20 | ACCEPTED | 0.11 s | 5 | details |
| #21 | ACCEPTED | 0.08 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.13 s | 5 | details |
| #25 | ACCEPTED | 0.08 s | 5 | details |
| #26 | ACCEPTED | 0.42 s | 5 | details |
| #27 | ACCEPTED | 0.08 s | 5 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:54:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for (int j = 0; j < toCheck.size(); j++) {
| ~~^~~~~~~~~~~~~~~~
input/code.cpp:60:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for (int k = 0; k < rowReach[toCheck[j]].size(); k++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp:96:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
96 | for (int j = 0; j < rowReach[y1].size(); j++) {
| ~~^~~~~~~~~~~~~~~~~~~~~
input/code.cpp:105:23: warning: comparison of integer expressions of different signed...Code
#include <bits/stdc++.h>
using namespace std;
bool safe[250][250];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("output.txt", "r", stdin);
int n, m, q;
cin >> n >> m >> q;
unordered_set<int>* rowAccess = new unordered_set<int>[n];
vector<int>* rowReach = new vector<int>[n];
for (int i = 0; i < n; i++) {
string row;
cin >> row;
unordered_set<int> foundRows;
for (int j = 0; j < m; j++) {
bool isSafe = row[j] == '.';
safe[i][j] = isSafe;
// cout << "Safe? " << isSafe << endl;
if (!isSafe) continue;
rowAccess[i].insert(j);
for (int k = 0; k < i; k++) {
if (rowAccess[k].find(j) != rowAccess[k].end() && foundRows.find(k) == foundRows.end()) {
rowReach[i].push_back(k);
rowReach[k].push_back(i);
foundRows.insert(k);
}
}
}
}
int distance[250][250];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
distance[i][j] = -1;
}
}
// Qualqulate the reach distance thng to the other rows - Should be O(n^2) max
for (int i = 0; i < n; i++) {
distance[i][i] = 0;
bool checked[250] = {};
// checked[i] = true;
vector<int> toCheck = {i};
int steps = 0;
while (toCheck.size() > 0) {
vector<int> newCheck;
for (int j = 0; j < toCheck.size(); j++) {
if (checked[toCheck[j]]) continue;
checked[toCheck[j]] = true;
// cout << i << " " << toCheck[j] << " " << steps << endl;
// cout << "a" << endl;
distance[i][toCheck[j]] = steps;
for (int k = 0; k < rowReach[toCheck[j]].size(); k++) {
if (checked[rowReach[toCheck[j]][k]]) continue;
newCheck.push_back(rowReach[toCheck[j]][k]);
}
}
toCheck = newCheck;
++steps;
}
}
int* results = new int[q];
for (int i = 0; i < q; i++) {
int y1, x1, y2, x2;
cin >> y1 >> x1 >> y2 >> x2;
--y1; --x1; --y2; --x2;
if (distance[y1][y2] == -1) {
results[i] = -1;
continue;
}
if (y1 == y2) {
if (x1 == x2) {
results[i] = 0;
continue;
} else {
results[i] = 1;
continue;
}
}
// cout << "Row reach from " << y1 << " to " << y2 << " is " << distance[y1][y2] << endl;
int result = 2 * distance[y1][y2] - 1;
bool secondColumnMatch = false;
for (int j = 0; j < rowReach[y1].size(); j++) {
if (distance[rowReach[y1][j]][y2] == distance[y1][y2] - 1 && safe[rowReach[y1][j]][x1]) {
secondColumnMatch = true;
break;
}
}
result += !secondColumnMatch;
bool secLastColumnMatch = false;
for (int j = 0; j < rowReach[y2].size(); j++) {
if (distance[y1][rowReach[y2][j]] == distance[y1][y2] - 1 && safe[rowReach[y2][j]][x2]) {
secLastColumnMatch = true;
break;
}
}
result += !secLastColumnMatch;
if (result == 1 && x1 != x2) {
++result;
}
results[i] = result;
}
for (int i = 0; i < q; i++) {
cout << results[i] << '\n';
}
// cout << "finished" << endl;
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: WRONG ANSWER
| input |
|---|
| 10 10 10 ***.*.**** ********** *.******** .*.***.**. ... |
| correct output |
|---|
| 3 4 2 3 4 ... |
| user output |
|---|
| 3 3 2 3 4 ... |
Feedback: Incorrect character on line 2 col 1: expected "4", got "3"
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: 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: WRONG ANSWER
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 3 3 3 3 3 ... |
Feedback: Incorrect character on line 75 col 1: expected "4", got "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: WRONG ANSWER
| input |
|---|
| 80 80 200000 *******.*****.*..*..****...***... |
| correct output |
|---|
| 2 3 1 2 2 ... |
| user output |
|---|
| 2 3 1 2 2 ... |
Feedback: Incorrect character on line 82466 col 1: expected "4", got "3"
Test 15
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 *....*..*..*..**..*.........**... |
| correct output |
|---|
| 3 2 2 2 2 ... |
| user output |
|---|
| 3 2 2 2 2 ... |
Test 16
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 ..*....*..*......*.**.*.*..***... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| 2 2 2 2 2 ... |
Test 17
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 *..*.*****.*********.****.****... |
| correct output |
|---|
| 3 3 2 2 2 ... |
| user output |
|---|
| 3 3 2 2 2 ... |
Test 18
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 *********.**********.******.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 3 3 3 3 3 ... |
Feedback: Incorrect character on line 441 col 1: expected "4", got "3"
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 ... |
