| Task: | Hypyt |
| Sender: | alli |
| Submission time: | 2025-10-28 17:35:17 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 10 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 10 |
| #2 | RUNTIME ERROR | 0 |
| #3 | RUNTIME ERROR | 0 |
| #4 | RUNTIME ERROR | 0 |
| #5 | RUNTIME ERROR | 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.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 | RUNTIME ERROR | 0.13 s | 2, 5 | details |
| #7 | RUNTIME ERROR | 0.18 s | 2, 5 | details |
| #8 | RUNTIME ERROR | 0.12 s | 2, 5 | details |
| #9 | RUNTIME ERROR | 0.01 s | 3, 4, 5 | details |
| #10 | RUNTIME ERROR | 0.01 s | 3, 4, 5 | details |
| #11 | RUNTIME ERROR | 0.01 s | 3, 4, 5 | details |
| #12 | RUNTIME ERROR | 0.02 s | 4, 5 | details |
| #13 | RUNTIME ERROR | 0.02 s | 4, 5 | details |
| #14 | RUNTIME ERROR | 0.02 s | 4, 5 | details |
| #15 | RUNTIME ERROR | 0.12 s | 5 | details |
| #16 | RUNTIME ERROR | 0.18 s | 5 | details |
| #17 | RUNTIME ERROR | 0.12 s | 5 | details |
| #18 | RUNTIME ERROR | 0.08 s | 5 | details |
| #19 | RUNTIME ERROR | 0.10 s | 5 | details |
| #20 | RUNTIME ERROR | 0.10 s | 5 | details |
| #21 | RUNTIME ERROR | 0.11 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.47 s | 5 | details |
| #26 | RUNTIME ERROR | 0.06 s | 5 | details |
| #27 | RUNTIME ERROR | 0.34 s | 5 | details |
Code
#include <bits/stdc++.h>
#define M 10000000
typedef long long ll;
using namespace std;
int n, m, q, u;
int d[1777][1777];
int z[70707];
vector<int> s;
vector<int> v[255];
vector<string> input;
int pos0(int x, int y) {
return x*m+y+1;
}
int 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 = 0; i < n; i++) {
string s; cin >> s;
input.push_back(s);
}
for (int i = 0; i < n; i++) {
for (int k = 0; k < m; k++) {
bool ikm = input[i][k] == '*';
int pos1 = pos0(i, k);
if (!ikm) s.push_back(pos1);
for (int j = 0; j < n; j++) {
for (int l = 0; l < m; l++) {
int pos2 = pos0(j, l);
if (pos1 == pos2) continue;
bool jlm = input[j][l] == '*';
if (ikm) z[pos1] = 1;
if (jlm) z[pos2] = 1;
if (ikm || jlm || (i != j && k != l)) {
d[pos1][pos2] = M;
}
else{
v[pos1].push_back(pos2);
d[pos1][pos2] = 1;
}
}
}
}
}
int u = 0;
//cout << "s.size(): " << s.size() << endl;
for (int k : s) {
for (int i : s) {
for (int j : s) {
d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
u++;
}
}
}
//cout << "amount of loops: " << u << endl;
for (int i = 1; i <= q; i++) {
int a1, b1, a2, b2;
cin >> a1 >> b1 >> a2 >> b2;
int dist = d[pos1(a1,b1)][pos1(a2,b2)];
if (dist == M) cout << "-1\n";
else cout << dist << "\n";
}
/*for (ll i = 1; i <= n*m; i++) {
for (int j = 1; j <= n*m; j++) {
if (d[i][j] == M) cout << "X ";
else cout << d[i][j] << " ";
} cout << "\n";
}
cout << "\n";
cout << d[pos1(1,1)][pos1(1,3)] << "\n";
cout << d[pos1(2,2)][pos1(2,2)] << "\n";
cout << d[pos1(1,1)][pos1(4,5)] << "\n";
cout << d[pos1(4,5)][pos1(2,4)] << "\n";
cout << d[pos1(3,6)][pos1(2,2)] << "\n";*/
}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: 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: RUNTIME ERROR
| input |
|---|
| 250 250 250 .*...*.....*******..**...*....... |
| correct output |
|---|
| 2 3 3 2 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 7
Group: 2, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 8
Group: 2, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 9
Group: 3, 4, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 40 40 200000 ...*.**.*..*.............*.*..... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 10
Group: 3, 4, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 40 40 200000 **.**..*.*.*.******....****.*.... |
| correct output |
|---|
| 2 1 3 2 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 11
Group: 3, 4, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Test 12
Group: 4, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 80 80 200000 *....**.***..****...*.....*...... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 13
Group: 4, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 80 80 200000 .***.*..*.***..*****....**...*... |
| correct output |
|---|
| 3 2 2 3 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 14
Group: 4, 5
Verdict: RUNTIME ERROR
| input |
|---|
| 80 80 200000 *******.*****.*..*..****...***... |
| correct output |
|---|
| 2 3 1 2 2 ... |
| user output |
|---|
| (empty) |
Test 15
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 *....*..*..*..**..*.........**... |
| correct output |
|---|
| 3 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 16
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 ..*....*..*......*.**.*.*..***... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 17
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 *..*.*****.*********.****.****... |
| correct output |
|---|
| 3 3 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 18
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 *********.**********.******.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Test 19
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| (empty) |
Test 20
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 ..****************************... |
| correct output |
|---|
| 57 155 38 65 98 ... |
| user output |
|---|
| (empty) |
Test 21
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 498 498 498 498 498 ... |
| user output |
|---|
| (empty) |
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: RUNTIME ERROR
| input |
|---|
| 250 250 200000 ................................. |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
Test 27
Group: 5
Verdict: RUNTIME ERROR
| input |
|---|
| 250 250 200000 ******************************... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
