| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 112399 | keanu | K번째 경로 (IZhO11_kthpath) | Cpython 3 | 23 ms | 3332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
n,m = input().split(' ')
n = int(n)
m = int(m)
tree = []
for i in range(n):
inputs=input()
tree.append([])
for j in range(m):
tree[i].append(inputs[j])
possibles=[]
leng=m+n-1
stack = [([0,0], tree[0][0])]
while len(stack)>0:
a = stack.pop()
i = a[0][0]
j = a[0][1]
stri=a[1]
try:
tree[i][j+1]
if len( stri+tree[i][j+1])==leng:
possibles.append(stri+tree[i][j+1])
else:
stack.append( ([i, j+1], stri+tree[i][j+1]))
except IndexError:
pass
try:
tree[i+1][j]
if len( stri+tree[i+1][j])==leng:
possibles.append(stri+tree[i+1][j])
else:
stack.insert(0, ([i+1, j], stri+tree[i+1][j]))
except IndexError:
pass
possibles.sort()
possibles
print(possibles[int(input())-1])
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
