Submission #65658824
Source Code Expand
Copy
def li():return list(map(int,input().split()))from collections import dequeq=deque()h,w=li()inf=1<<60d=[[inf]*w for _ in range(h)]s=[list(input()) for _ in range(h)]for i in range(h):for j in range(w):if s[i][j]=="E":q.append((i,j))d[i][j]=0dxy=[0,1,0,-1]ans=["<","^",">","v"]while q:y,x=q.popleft()for i in range(4):ny,nx=y+dxy[i],x+dxy[(i+1)%4]if 0<=ny<h and 0<=nx<w and s[ny][nx]=="." and d[ny][nx]>d[y][x]+1:s[ny][nx]=ans[i]
def li():return list(map(int,input().split()))
from collections import deque
q=deque()
h,w=li()
inf=1<<60
d=[[inf]*w for _ in range(h)]
s=[list(input()) for _ in range(h)]
for i in range(h):
for j in range(w):
if s[i][j]=="E":
q.append((i,j))
d[i][j]=0
dxy=[0,1,0,-1]
ans=["<","^",">","v"]
while q:
y,x=q.popleft()
for i in range(4):
ny,nx=y+dxy[i],x+dxy[(i+1)%4]
if 0<=ny<h and 0<=nx<w and s[ny][nx]=="." and d[ny][nx]>d[y][x]+1:
s[ny][nx]=ans[i]
d[ny][nx]=d[y][x]+1
q.append((ny,nx))
for ai in s:
print("".join(ai))
Submission Info
| Submission Time | |
|---|---|
| Task | D - Escape Route |
| User | juten |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 400 |
| Code Size | 642 Byte |
| Status | AC |
| Exec Time | 381 ms |
| Memory | 159440 KB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt, 02_corner_03.txt, 02_corner_04.txt, 02_corner_05.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 70 ms | 76764 KB |
| 00_sample_01.txt | AC | 69 ms | 76712 KB |
| 00_sample_02.txt | AC | 70 ms | 76948 KB |
| 01_random_00.txt | AC | 179 ms | 127892 KB |
| 01_random_01.txt | AC | 182 ms | 114996 KB |
| 01_random_02.txt | AC | 246 ms | 150936 KB |
| 01_random_03.txt | AC | 381 ms | 144584 KB |
| 01_random_04.txt | AC | 184 ms | 122928 KB |
| 01_random_05.txt | AC | 214 ms | 130880 KB |
| 01_random_06.txt | AC | 189 ms | 133784 KB |
| 01_random_07.txt | AC | 321 ms | 149444 KB |
| 01_random_08.txt | AC | 195 ms | 129132 KB |
| 01_random_09.txt | AC | 218 ms | 117804 KB |
| 01_random_10.txt | AC | 329 ms | 133212 KB |
| 01_random_11.txt | AC | 257 ms | 159440 KB |
| 01_random_12.txt | AC | 266 ms | 155320 KB |
| 01_random_13.txt | AC | 377 ms | 142576 KB |
| 01_random_14.txt | AC | 217 ms | 133100 KB |
| 01_random_15.txt | AC | 329 ms | 150040 KB |
| 02_corner_00.txt | AC | 173 ms | 130484 KB |
| 02_corner_01.txt | AC | 135 ms | 129860 KB |
| 02_corner_02.txt | AC | 187 ms | 146120 KB |
| 02_corner_03.txt | AC | 78 ms | 81984 KB |
| 02_corner_04.txt | AC | 94 ms | 83508 KB |
| 02_corner_05.txt | AC | 271 ms | 135688 KB |