Task: | Abandoned warehouse |
Sender: | zilakkio |
Submission time: | 2024-09-09 17:49:11 +0300 |
Language: | Python3 (CPython3) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.02 s | details |
#2 | ACCEPTED | 0.02 s | details |
#3 | WRONG ANSWER | 0.02 s | details |
#4 | WRONG ANSWER | 0.02 s | details |
#5 | WRONG ANSWER | 0.02 s | details |
#6 | ACCEPTED | 0.29 s | details |
#7 | TIME LIMIT EXCEEDED | -- | details |
#8 | TIME LIMIT EXCEEDED | -- | details |
#9 | TIME LIMIT EXCEEDED | -- | details |
#10 | TIME LIMIT EXCEEDED | -- | details |
#11 | ACCEPTED | 0.11 s | details |
#12 | ACCEPTED | 0.03 s | details |
#13 | TIME LIMIT EXCEEDED | -- | details |
#14 | ACCEPTED | 0.02 s | details |
#15 | ACCEPTED | 0.02 s | details |
#16 | TIME LIMIT EXCEEDED | -- | details |
Code
import sys sys.setrecursionlimit(10 ** 6) height, width = map(int, input().split()) grid = [] for h in range(height): row = list(input()) grid.append(row) A_pos = (0, 0) B_pos = (0, 0) for h, row in enumerate(grid): for w, el in enumerate(row): if el == "A": A_pos = (h, w) if el == "B": B_pos = (h, w) best_sol = "" def dfs(h, w, directions: str, vis: list[list[bool]]): global best_sol if h >= height or w >= width or h < 0 or w < 0 or grid[h][w] == "#" or vis[h][w]: return visit = vis.copy() visit[h][w] = True if grid[h][w] == "B": if (not best_sol) or len(best_sol) > len(directions): best_sol = directions return dfs(h - 1, w, directions + "U", visit.copy()) dfs(h, w + 1, directions + "R", visit.copy()) dfs(h + 1, w, directions + "D", visit.copy()) dfs(h, w - 1, directions + "L", visit.copy()) visited = [[False for _ in range(width)] for _ in range(height)] dfs(A_pos[0], A_pos[1], "", visited) if best_sol: print("YES") print(len(best_sol)) print(best_sol) else: print("NO")
Test details
Test 1
Verdict: ACCEPTED
input |
---|
10 10 ##.A###### #.##.##.## #####..### .######### ... |
correct output |
---|
NO |
user output |
---|
NO |
Test 2
Verdict: ACCEPTED
input |
---|
10 10 B#..##.#.. #....A##.. #.....#..# .#......#. ... |
correct output |
---|
NO |
user output |
---|
NO |
Test 3
Verdict: WRONG ANSWER
input |
---|
10 10 ...#..A.#. ....B...## ...#...... .......... ... |
correct output |
---|
YES 3 LLD |
user output |
---|
YES 23 RDDRRDDDDLUUULDLUUULULD |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 10 .#........ .......... .......... ........#. ... |
correct output |
---|
YES 1 R |
user output |
---|
YES 23 UUUUUUUURRDDDDDLDDRDDLU |
Test 5
Verdict: WRONG ANSWER
input |
---|
10 10 .......... .......... .......... .......... ... |
correct output |
---|
YES 3 RDD |
user output |
---|
YES 59 UUUUURRRRRRDDDDDDDDDLUUUUUUUUL... |
Test 6
Verdict: ACCEPTED
input |
---|
1000 1000 ##.###..######.#########.###.#... |
correct output |
---|
NO |
user output |
---|
NO |
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: ACCEPTED
input |
---|
1000 3 A#B .#. .#. .#. ... |
correct output |
---|
YES 2000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... |
user output |
---|
YES 2000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... Truncated |
Test 12
Verdict: ACCEPTED
input |
---|
3 1000 A................................ |
correct output |
---|
YES 2000 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... |
user output |
---|
YES 2000 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... Truncated |
Test 13
Verdict: TIME LIMIT EXCEEDED
input |
---|
999 999 A#...#...#...#...#...#...#...#... |
correct output |
---|
YES 499998 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD... |
user output |
---|
(empty) |
Test 14
Verdict: ACCEPTED
input |
---|
1 3 A.B |
correct output |
---|
YES 2 RR |
user output |
---|
YES 2 RR |
Test 15
Verdict: ACCEPTED
input |
---|
2 2 ## AB |
correct output |
---|
YES 1 R |
user output |
---|
YES 1 R |
Test 16
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 1000 A................................ |
correct output |
---|
YES 1998 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... |
user output |
---|
(empty) |