| Task: | Abandoned warehouse |
| Sender: | aalto26bm_011 |
| Submission time: | 2026-09-07 17:49:59 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.07 s | details |
| #2 | WRONG ANSWER | 0.07 s | details |
| #3 | WRONG ANSWER | 0.07 s | details |
| #4 | WRONG ANSWER | 0.07 s | details |
| #5 | WRONG ANSWER | 0.07 s | details |
| #6 | WRONG ANSWER | 0.25 s | details |
| #7 | TIME LIMIT EXCEEDED | -- | details |
| #8 | TIME LIMIT EXCEEDED | -- | details |
| #9 | TIME LIMIT EXCEEDED | -- | details |
| #10 | TIME LIMIT EXCEEDED | -- | details |
| #11 | WRONG ANSWER | 0.17 s | details |
| #12 | WRONG ANSWER | 0.14 s | details |
| #13 | TIME LIMIT EXCEEDED | -- | details |
| #14 | WRONG ANSWER | 0.07 s | details |
| #15 | WRONG ANSWER | 0.07 s | details |
| #16 | TIME LIMIT EXCEEDED | -- | details |
Code
import queue
n, m = [int(i) for i in input().split()]
h = n
w = m
maze = []
start_pos = None
end_pos = None
for y in range(h):
line = list(input().strip())
for x, c in enumerate(line):
if c == "A":
start_pos = (x, y)
elif c == "B":
end_pos = (x, y)
maze.append(line)
search_queue = queue.Queue()
search_queue.put((start_pos[0], start_pos[1], (-1, -1)))
visited = [[False] * w for _ in range(h)]
visited[start_pos[1]][start_pos[0]] = True
dist = [[(-1, "", (-1, -1))] * w for _ in range(h)]
dist[start_pos[1]][start_pos[0]] = (0, "", (-1, -1))
moves = [(0, 1, "D"), (0, -1, "U"), (1, 0, "R"), (-1, 0, "L")]
found = False
found_dist = -1
while search_queue.qsize() != 0:
i = search_queue.get()
x, y, (old_x, old_y) = i
print(i)
for dx, dy, direction in moves:
new_x = x + dx
new_y = y + dy
print(new_x, new_y)
if new_x < 0 or new_x >= w or new_y < 0 or new_y >= h:
continue
if visited[new_y][new_x]:
continue
if maze[new_y][new_x] == "#":
continue
visited[new_y][new_x] = True
old_dist, old_dir, _ = dist[y][x]
dist[new_y][new_x] = (old_dist + 1, direction, (x, y))
search_queue.put((new_x, new_y, (x, y)))
if (new_x, new_y) == end_pos:
found = True
found_dist = old_dist + 1
search_queue = queue.Queue()
break
if found:
print("YES")
print(found_dist)
path = []
x, y = end_pos
while True:
dis, direction, (prev_x, prev_y) = dist[y][x]
path.append(direction)
if dis == 0:
break
x, y = prev_x, prev_y
for i in reversed(path):
print(i, end="")
print()
else:
print("NO")
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 ##.A###### #.##.##.## #####..### .######### ... |
| correct output |
|---|
| NO |
| user output |
|---|
| (3, 0, (-1, -1)) 3 1 3 -1 4 0 2 0 ... |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 B#..##.#.. #....A##.. #.....#..# .#......#. ... |
| correct output |
|---|
| NO |
| user output |
|---|
| (5, 1, (-1, -1)) 5 2 5 0 6 1 4 1 ... |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 ...#..A.#. ....B...## ...#...... .......... ... |
| correct output |
|---|
| YES 3 LLD |
| user output |
|---|
| (6, 0, (-1, -1)) 6 1 6 -1 7 0 5 0 ... |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 .#........ .......... .......... ........#. ... |
| correct output |
|---|
| YES 1 R |
| user output |
|---|
| (7, 8, (-1, -1)) 7 9 7 7 8 8 YES ... |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 .......... .......... .......... .......... ... |
| correct output |
|---|
| YES 3 RDD |
| user output |
|---|
| (3, 5, (-1, -1)) 3 6 3 4 4 5 2 5 ... |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 1000 1000 ##.###..######.#########.###.#... |
| correct output |
|---|
| NO |
| user output |
|---|
| (370, 335, (-1, -1)) 370 336 370 334 371 335 369 335 ... |
Test 7
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 1000 ####.#.###....#.......##.##.#.... |
| correct output |
|---|
| YES 626 LLLDDRDDDDLDLDDLLLLLDDDDLLDLDL... |
| user output |
|---|
| (empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 1000 ....#.##......#....#......#...... |
| correct output |
|---|
| YES 364 LULULLULLLULLLLLUULLLLUUULLLLL... |
| user output |
|---|
| (empty) |
Test 9
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 1000 .................#......#........ |
| correct output |
|---|
| YES 1003 LLLLLLLLLLLLLLLLLLLLLLLLLDLLLL... |
| user output |
|---|
| (empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 1000 ................................. |
| correct output |
|---|
| YES 947 LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL... |
| user output |
|---|
| (empty) |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 1000 3 A#B .#. .#. .#. ... |
| correct output |
|---|
| YES 2000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... |
| user output |
|---|
| (0, 0, (-1, -1)) 0 1 0 -1 1 0 -1 0 ... |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 3 1000 A................................ |
| correct output |
|---|
| YES 2000 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... |
| user output |
|---|
| (0, 0, (-1, -1)) 0 1 0 -1 1 0 -1 0 ... |
Test 13
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 999 999 A#...#...#...#...#...#...#...#... |
| correct output |
|---|
| YES 499998 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... |
| user output |
|---|
| (empty) |
Test 14
Verdict: WRONG ANSWER
| input |
|---|
| 1 3 A.B |
| correct output |
|---|
| YES 2 RR |
| user output |
|---|
| (0, 0, (-1, -1)) 0 1 0 -1 1 0 -1 0 ... |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 2 2 ## AB |
| correct output |
|---|
| YES 1 R |
| user output |
|---|
| (0, 1, (-1, -1)) 0 2 0 0 1 1 YES ... |
Test 16
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 1000 A................................ |
| correct output |
|---|
| YES 1998 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... |
| user output |
|---|
| (empty) |
