| Task: | Suunnistus |
| Sender: | alberthenriksson |
| Submission time: | 2025-01-18 16:59:37 +0200 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| #2 | RUNTIME ERROR | 0 |
| #3 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.01 s | 3 | details |
| #2 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
| #3 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
| #4 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
| #5 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #6 | RUNTIME ERROR | 0.01 s | 1, 2, 3 | details |
| #7 | RUNTIME ERROR | 0.02 s | 2, 3 | details |
| #8 | RUNTIME ERROR | 0.02 s | 2, 3 | details |
| #9 | RUNTIME ERROR | 0.02 s | 2, 3 | details |
| #10 | RUNTIME ERROR | 0.02 s | 3 | details |
| #11 | RUNTIME ERROR | 0.02 s | 3 | details |
| #12 | RUNTIME ERROR | 0.02 s | 3 | details |
| #13 | RUNTIME ERROR | 0.02 s | 3 | details |
| #14 | RUNTIME ERROR | 0.02 s | 2, 3 | details |
| #15 | WRONG ANSWER | 0.01 s | 3 | details |
| #16 | RUNTIME ERROR | 0.01 s | 3 | details |
| #17 | RUNTIME ERROR | 0.03 s | 2, 3 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:51:18: warning: 'r2' may be used uninitialized in this function [-Wmaybe-uninitialized]
51 | dist[r1][r2] = 0;
| ~~~~~~~~~~~~~^~~
input/code.cpp:51:18: warning: 'r1' may be used uninitialized in this function [-Wmaybe-uninitialized]
input/code.cpp:53:16: warning: 'taly' may be used uninitialized in this function [-Wmaybe-uninitialized]
53 | int ans = f(talx, taly);
| ~^~~~~~~~~~~~
input/code.cpp:53:16: warning: 'talx' may be used uninitialized in this function [-Wmaybe-uninitialized]Code
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
string rud[503][503];
int dist[503][503];
int m, n;
int f(int x, int y) {
if (dist[x][y]== 1e7) {
return 1e7;
}
if (rud[x][y]== "E") {
dist[x][y] = 0;
return 0;
}
if (rud[x][y] == "#") {
dist[x][y] = 1e7;
return 1e7;
}
dist[x][y] = 1e7;
return min(min(f(x-1, y), f(x+1, y)), min(f(x, y+1), f(x, y-1))) +1;
}
int main() {
int n, m, k;
int talx, taly;
int r1, r2;
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
string sr1;
cin >> sr1;
rud[i][j] = sr1;
if (sr1 == "S") {
talx = i;
taly = j;
}
if (sr1 == "E") {
r1 = i;
r2 = j;
}
}
}
for (int i = 0; i <= 501; i++) {
rud[0][i] = "#";
rud[n+1][i] = "#";
rud[i][0] = "#";
rud[i][m+1] = "#";
}
dist[r1][r2] = 0;
f(talx, taly);
int ans = f(talx, taly);
if (ans < 1e7) {
cout << ans;
}
else {
cout << -1;
}
}Test details
Test 1
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 10 10 9 S293#35616 #662963731 54975451#7 5162589168 ... |
| correct output |
|---|
| 25 |
| user output |
|---|
| (empty) |
Test 2
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 0 ................................. |
| correct output |
|---|
| 301 |
| user output |
|---|
| (empty) |
Test 3
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 0 .#.........#.#..##..#............ |
| correct output |
|---|
| 253 |
| user output |
|---|
| (empty) |
Test 4
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 0 ...#......##.##.#.#..##..#..##... |
| correct output |
|---|
| -1 |
| user output |
|---|
| (empty) |
Test 5
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 1 0 . . . . ... |
| correct output |
|---|
| 77 |
| user output |
|---|
| -1 |
Test 6
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 1 500 0 ................................. |
| correct output |
|---|
| 166 |
| user output |
|---|
| (empty) |
Test 7
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 9 ................................. |
| correct output |
|---|
| 3447 |
| user output |
|---|
| (empty) |
Test 8
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 9 .#........#..................#... |
| correct output |
|---|
| 4952 |
| user output |
|---|
| (empty) |
Test 9
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 9 ##.########.##########.#..#...... |
| correct output |
|---|
| -1 |
| user output |
|---|
| (empty) |
Test 10
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 9 623475428948841896621266296765... |
| correct output |
|---|
| 205 |
| user output |
|---|
| (empty) |
Test 11
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 9 7##814125813#3463#272134469457... |
| correct output |
|---|
| 157 |
| user output |
|---|
| (empty) |
Test 12
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 9 ##67##36##5#3###67###8972#61##... |
| correct output |
|---|
| -1 |
| user output |
|---|
| (empty) |
Test 13
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 9 ....................#...#........ |
| correct output |
|---|
| 1313 |
| user output |
|---|
| (empty) |
Test 14
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 499 499 9 S#...#...#...#...#...#...#...#... |
| correct output |
|---|
| 1124942 |
| user output |
|---|
| (empty) |
Test 15
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 500 1 9 1 6 1 3 ... |
| correct output |
|---|
| 332 |
| user output |
|---|
| -1 |
Test 16
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 1 500 9 996327784392827829434482995353... |
| correct output |
|---|
| 135 |
| user output |
|---|
| (empty) |
Test 17
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 500 500 9 ................................. |
| correct output |
|---|
| -1 |
| user output |
|---|
| (empty) |
