| Task: | Hypyt |
| Sender: | Tmotomaster |
| Submission time: | 2025-11-02 21:12:01 +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 | 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.01 s | 1, 2, 3, 4, 5 | details |
| #6 | TIME LIMIT EXCEEDED | -- | 2, 5 | details |
| #7 | TIME LIMIT EXCEEDED | -- | 2, 5 | details |
| #8 | TIME LIMIT EXCEEDED | -- | 2, 5 | details |
| #9 | WRONG ANSWER | 0.24 s | 3, 4, 5 | details |
| #10 | WRONG ANSWER | 0.24 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.24 s | 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 | ACCEPTED | 0.21 s | 5 | details |
| #20 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #21 | ACCEPTED | 0.20 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 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #25 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #26 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #27 | ACCEPTED | 0.21 s | 5 | details |
Compiler report
input/code.cpp: In member function 'void Row::propagateReach(int, int, int)':
input/code.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Row*>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for (int i = 0; i < reachableFrom.size(); i++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~
input/code.cpp: In member function 'void Column::propagateReach(int, int, int)':
input/code.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Column*>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | for (int i = 0; i < reachableFrom.size(); i++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:104:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
104 | for (int k = 0; k < safeCols.siz...Code
#include <iostream>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
int n, m, q;
int rowReach[250][250];
int colReach[250][250];
struct Row {
int idx;
vector<Row*> reachableFrom;
int lastChecked = -1;
Row(int i) {
idx = i;
}
void addReachable(Row* r) {
reachableFrom.push_back(r);
}
void propagateReach(int j, int count, int lc) {
rowReach[idx][j] = count;
lastChecked = lc;
for (int i = 0; i < reachableFrom.size(); i++) {
if (count < rowReach[reachableFrom[i]->idx][j]) {
reachableFrom[i]->propagateReach(j, count+1, lc);
}
}
}
};
struct Column { // I'm too lazy to simplify into one struct, but oh well; not important today (:
int idx;
vector<Column*> reachableFrom;
int lastChecked = -1;
Column(int i) {
idx = i;
}
void addReachable(Column* c) {
reachableFrom.push_back(c);
}
void propagateReach(int j, int count, int lc) {
colReach[idx][j] = count;
lastChecked = lc;
for (int i = 0; i < reachableFrom.size(); i++) {
if (count < colReach[reachableFrom[i]->idx][j]) {
reachableFrom[i]->propagateReach(j, count+1, lc);
}
}
}
};
int main() {
// freopen("spiral.txt", "r", stdin);
cin >> n >> m >> q;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
rowReach[i][j] = 2147483647;
}
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
colReach[i][j] = 2147483647;
}
}
Row** rows = new Row*[n];
Column** cols = new Column*[m];
for (int i = 0; i < n; i++) {
rows[i] = new Row(i);
}
for (int i = 0; i < m; i++) {
cols[i] = new Column(i);
}
unordered_set<int>* rowAccess = new unordered_set<int>[n];
unordered_set<int>* colAccess = new unordered_set<int>[m];
for (int i = 0; i < n; i++) {
string row;
cin >> row;
unordered_set<int> foundRows;
vector<int> safeCols;
for (int j = 0; j < m; j++) {
if (row[j] != '.') continue;
for (int k = 0; k < i; k++) {
if (rowAccess[k].find(j) != rowAccess[k].end() && foundRows.find(k) == foundRows.end()) {
rows[i]->addReachable(rows[k]);
rows[k]->addReachable(rows[i]);
foundRows.insert(k);
// cout << i << ' ' << k << " | " << j << endl;
}
}
rowAccess[i].insert(j);
for (int k = 0; k < safeCols.size(); k++) {
if (colAccess[safeCols[k]].find(j) != colAccess[safeCols[k]].end()) continue;
cols[j]->addReachable(cols[safeCols[k]]);
cols[safeCols[k]]->addReachable(cols[j]);
colAccess[safeCols[k]].insert(j);
}
safeCols.push_back(j);
}
}
for (int i = 0; i < n; i++) {
if (rows[i] == nullptr) continue;
rows[i]->propagateReach(rows[i]->idx, 0, i);
}
for (int i = 0; i < m; i++) {
if (cols[i] == nullptr) continue;
cols[i]->propagateReach(cols[i]->idx, 0, i);
}
int* result = 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 && x1 == x2) {
result[i] = 0;
} else if (rowReach[y1][y2] == 2147483647 || colReach[x1][x2] == 2147483647) {
result[i] = -1;
} else {
result[i] = rowReach[y1][y2] + colReach[x1][x2];
}
}
for (int i = 0; i < q; i++) {
cout << result[i] << '\n';
}
// for (int i = 0; i < n; i++) {
// for (int j = 0; j < n; j++) {
// cout << rowReach[i][j] << " ";
// }
// cout << endl;
// }
// for (int i = 0; i < m; i++) {
// for (int j = 0; j < m; j++) {
// cout << colReach[i][j] << " ";
// }
// cout << endl;
// }
// 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: 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: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 250 .*...*.....*******..**...*....... |
| correct output |
|---|
| 2 3 3 2 2 ... |
| user output |
|---|
| (empty) |
Test 7
Group: 2, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| (empty) |
Test 8
Group: 2, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| (empty) |
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: 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: ACCEPTED
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| 104 422 145 93 65 ... |
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: 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: 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: ACCEPTED
| input |
|---|
| 250 250 200000 ******************************... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| 0 0 0 0 0 ... |
