| Task: | Hypyt |
| Sender: | alli |
| Submission time: | 2025-10-28 21:10:06 +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 | WRONG ANSWER | 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.05 s | 2, 5 | details |
| #7 | ACCEPTED | 0.06 s | 2, 5 | details |
| #8 | ACCEPTED | 0.06 s | 2, 5 | details |
| #9 | ACCEPTED | 0.45 s | 3, 4, 5 | details |
| #10 | ACCEPTED | 0.46 s | 3, 4, 5 | details |
| #11 | WRONG ANSWER | 0.45 s | 3, 4, 5 | details |
| #12 | ACCEPTED | 0.46 s | 4, 5 | details |
| #13 | ACCEPTED | 0.45 s | 4, 5 | details |
| #14 | WRONG ANSWER | 0.45 s | 4, 5 | details |
| #15 | ACCEPTED | 0.52 s | 5 | details |
| #16 | ACCEPTED | 0.53 s | 5 | details |
| #17 | ACCEPTED | 0.53 s | 5 | details |
| #18 | WRONG ANSWER | 0.55 s | 5 | details |
| #19 | WRONG ANSWER | 0.56 s | 5 | details |
| #20 | WRONG ANSWER | 0.55 s | 5 | details |
| #21 | ACCEPTED | 0.53 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.47 s | 5 | details |
| #25 | ACCEPTED | 0.48 s | 5 | details |
| #26 | ACCEPTED | 0.52 s | 5 | details |
| #27 | ACCEPTED | 0.55 s | 5 | details |
Code
#include <bits/stdc++.h>
#define M 1000000000
typedef long long ll;
using namespace std;
ll n, m, q, u;
int z[255][255];
ll d1[255][255];
ll d2[255][255];
ll f1[255][255];
ll f2[255][255];
vector<string> input;
ll pos0(int x, int y) {
return x*m+y+1;
}
ll pos1(int x, int y) {
return (x-1)*m+y;
}
int main() {
//ios_base::sync_with_stdio(false);
//cin.tie(nullptr);
//freopen(R"(C:\Users\Kymppi\Downloads\test_input.txt)", "r", stdin);
cin >> n >> m >> q;
for (int i = 1; i <= n; i++) {
string s; cin >> s;
input.push_back(s);
for (int j = 1; j <= m; j++) {
if (s[j-1] == '*') z[i][j] = 1;
}
}
/*for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) cout << z[i][j] << " ";
cout << "\n";
}*/
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (i == j) {d1[i][j] = 0; continue;}
d1[i][j] = M;
for (int l = 1; l <= m; l++) {
if (z[j][l]) continue;
if(!z[i][l]) {
d1[i][j] = 1;
d1[j][i] = 1;
break;
}
}
}
}
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= m; j++) {
if (i == j) {d2[i][j] = 0; continue;}
d2[i][j] = M;
for (int l = 1; l <= n; l++) {
if (z[l][j]) continue;
if(!z[l][i]) {
d2[i][j] = 1;
d2[j][i] = 1;
break;
}
}
}
}
for (int k = 1; k <= n; k++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
ll dist = d1[i][k]+d1[k][j];
if (dist < d1[i][j]) {
d1[i][j] = dist;
f1[i][j] = k;
}
}
}
}
//for (int k = 1; k <= m; k++) {
for (int k = 1; k <= m; k++) {
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= m; j++) {
ll dist = d2[i][k]+d2[k][j];
if (dist < d2[i][j]) {
d2[i][j] = dist;
f2[i][j] = k;
}
}
}
}
/*for (int i = 1; i <= n; i++) {
cout << "i " << i << ": ";
for (int j = 1; j <= n; j++) cout << d1[i][j] << " ";
cout << "\n";
} cout << "\n";
for (int i = 1; i <= m; i++) {
cout << "i " << i << ": ";
for (int j = 1; j <= m; j++) cout << d2[i][j] << " ";
cout << "\n";
}*/
for (int i = 1; i <= q; i++) {
int a1, b1, a2, b2;
cin >> a1 >> b1 >> a2 >> b2;
if (a1 == a2 && b1 == b2) {
cout << "0" << "\n";
continue;
}
ll dist = d1[a1][a2] + d2[b1][b2];
if (!f1[a1][a2] && z[a1][b2] && z[a2][b1]) dist++;
//else if (z[a1][b2] || z[a2][b1]) dist++;
//cout << "q " << i << ": ";
if (dist >= M || z[a1][b1] || z[a2][b2]) cout << "-1\n";
else cout << dist << "\n";
}
/*cout << "test area\n";
cout << f1[16][16] << "\n";
cout << f2[3][3] << "\n";
cout << d1[16][16] << "\n";
cout << d2[3][3] << "\n";*/
}Test details
Test 1 (public)
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
| input |
|---|
| 4 6 5 .*.*** *...** *****. *..*.* ... |
| correct output |
|---|
| 1 0 3 3 -1 |
| user output |
|---|
| 1 0 4 4 -1 |
Feedback: Incorrect character on line 3 col 1: expected "3", got "4"
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 |
|---|
| 4 4 2 4 4 ... |
Feedback: Incorrect character on line 1 col 1: expected "3", got "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: 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 4 3 ... |
Feedback: Incorrect character on line 4 col 1: expected "3", got "4"
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 192 col 1: expected "3", got "4"
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 16 col 1: expected "3", got "4"
Test 19
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| 104 422 145 93 65 ... |
Feedback: Incorrect character on line 1125 col 1: expected "3", got "4"
Test 20
Group: 5
Verdict: WRONG ANSWER
| input |
|---|
| 250 250 200000 ..****************************... |
| correct output |
|---|
| 57 155 38 65 98 ... |
| user output |
|---|
| 57 155 38 65 98 ... |
Feedback: Incorrect character on line 288 col 1: expected "3", got "4"
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 ... |
