| Task: | Hypyt |
| Sender: | Tmotomaster |
| Submission time: | 2025-11-04 21:32:45 +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.01 s | 1, 2, 3, 4, 5 | details |
| #2 | ACCEPTED | 0.01 s | 1, 2, 3, 4, 5 | details |
| #3 | ACCEPTED | 0.01 s | 1, 2, 3, 4, 5 | details |
| #4 | WRONG ANSWER | 0.01 s | 1, 2, 3, 4, 5 | details |
| #5 | WRONG ANSWER | 0.01 s | 1, 2, 3, 4, 5 | details |
| #6 | ACCEPTED | 0.19 s | 2, 5 | details |
| #7 | ACCEPTED | 0.19 s | 2, 5 | details |
| #8 | ACCEPTED | 0.11 s | 2, 5 | details |
| #9 | ACCEPTED | 0.18 s | 3, 4, 5 | details |
| #10 | ACCEPTED | 0.19 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.18 s | 3, 4, 5 | details |
| #12 | ACCEPTED | 0.20 s | 4, 5 | details |
| #13 | ACCEPTED | 0.20 s | 4, 5 | details |
| #14 | WRONG ANSWER | 0.19 s | 4, 5 | details |
| #15 | ACCEPTED | 0.42 s | 5 | details |
| #16 | ACCEPTED | 0.42 s | 5 | details |
| #17 | ACCEPTED | 0.33 s | 5 | details |
| #18 | WRONG ANSWER | 0.28 s | 5 | details |
| #19 | WRONG ANSWER | 0.21 s | 5 | details |
| #20 | WRONG ANSWER | 0.21 s | 5 | details |
| #21 | WRONG ANSWER | 0.20 s | 5 | details |
| #22 | ACCEPTED | 0.01 s | 1, 2, 3, 4, 5 | details |
| #23 | ACCEPTED | 0.01 s | 1, 2, 3, 4, 5 | details |
| #24 | ACCEPTED | 0.19 s | 5 | details |
| #25 | ACCEPTED | 0.18 s | 5 | details |
| #26 | ACCEPTED | 0.44 s | 5 | details |
| #27 | ACCEPTED | 0.21 s | 5 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:86:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
86 | for (int j = 0; j < rowReach[i].size(); j++) {
| ~~^~~~~~~~~~~~~~~~~~~~
input/code.cpp:104:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<RowJump*>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
104 | for (int j = 0; j < toCheck.size(); j++) {
| ~~^~~~~~~~~~~~~~~~
input/code.cpp:108:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
108 | for (int k = 0; k < rowReach[idx].size(); k++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~
input/code.cpp:144:23: warning: comparison of integer expressions of different signedness: 'in...Code
#include <bits/stdc++.h>
using namespace std;
bool safe[250][250];
struct RowJump {
int startRow;
int endRow;
int secondRow;
int secondToLast;
int rowJumps;
RowJump(int start) {
startRow = start;
}
void setEndRow(int r) {
endRow = r;
}
void setSecondRow(int r) {
secondRow = r;
}
void setSecondToLast(int r) {
secondToLast = r;
}
void setRowJumps(int j) {
rowJumps = j;
}
int getJumpCount(int startCol, int endCol) {
int jumps = rowJumps * 2 - 1;
if (!safe[secondRow][startCol]) {
++jumps;
}
if (!safe[secondToLast][endCol]) {
++jumps;
}
if (jumps == 1 && startCol != endCol) {
++jumps;
}
// cout << rowJumps << " " << jumps << endl;
return jumps;
}
};
int main() {
// 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);
}
}
}
}
// Calculate stuff
vector<RowJump*> rowJumps[250][250];
bool checked[250][250] = {};
for (int i = 0; i < n; i++) {
checked[i][i] = true;
vector<RowJump*> toCheck;
// cout << i << " " << rowReach[i].size() << endl;
for (int j = 0; j < rowReach[i].size(); j++) {
RowJump* newJump = new RowJump(i);
newJump->setSecondRow(rowReach[i][j]);
newJump->setSecondToLast(i);
newJump->setEndRow(rowReach[i][j]);
newJump->setRowJumps(1);
rowJumps[i][rowReach[i][j]].push_back(newJump);
toCheck.push_back(newJump);
}
int round = 1;
while (toCheck.size() > 0) {
// When adding RowJump*, set the previous row to secondToLast and current to lastRow.
// Do some cloning of previous row's RowJump to get secondRow.
// If row is available from multiple sources, just add multiple RowJump* to rowJumps.
// Don't add already checked to toCheck.
// Get dragged to gym and take a break.
++round;
vector<RowJump*> newCheck;
for (int j = 0; j < toCheck.size(); j++) {
int idx = toCheck[j]->endRow;
checked[i][idx] = true;
for (int k = 0; k < rowReach[idx].size(); k++) {
if (checked[rowReach[idx][k]]) continue;
RowJump* newJump = new RowJump(i);
newJump->setSecondRow(toCheck[j]->secondRow);
newJump->setSecondToLast(idx);
newJump->setEndRow(rowReach[idx][k]);
newJump->setRowJumps(round);
rowJumps[i][rowReach[idx][k]].push_back(newJump);
newCheck.push_back(newJump);
}
}
toCheck = newCheck;
}
}
// cout << "Processed data" << endl;
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 (y1 == y2) {
results[i] = (x1 == x2) ? 0 : 1;
continue;
}
if (rowJumps[y1][y2].size() == 0) {
results[i] = -1;
continue;
}
int minJumps = 2147483647;
// cout << rowJumps[y1][y2].size() << endl;
for (int i = 0; i < rowJumps[y1][y2].size(); i++) {
int jumpCount = rowJumps[y1][y2][i]->getJumpCount(x1, x2);
if (jumpCount < minJumps) {
minJumps = jumpCount;
}
if (jumpCount == rowJumps[y1][y2][i]->rowJumps * 2 - 1) break;
}
results[i] = minJumps;
}
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 -1 2 3 -1 ... |
Feedback: Incorrect character on line 2 col 1: expected "4", got "-1"
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: WRONG ANSWER
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| 3 3 3 3 -1 ... |
Feedback: Incorrect character on line 5 col 1: expected "3", got "-1"
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 147 col 1: expected "3", got "-1"
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 105 col 1: expected "3", got "-1"
Test 19
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| -1 -1 -1 -1 -1 ... |
Feedback: Incorrect character on line 1 col 1: expected "104", got "-1"
Test 20
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 ..****************************... |
| correct output |
|---|
| 57 155 38 65 98 ... |
| user output |
|---|
| -1 -1 -1 -1 -1 ... |
Feedback: Incorrect character on line 1 col 1: expected "57", got "-1"
Test 21
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 498 498 498 498 498 ... |
| user output |
|---|
| -1 -1 -1 -1 -1 ... |
Feedback: Incorrect character on line 1 col 1: expected "498", got "-1"
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 ... |
