#2327621

Solution for 1126: The Secret Number by n_knuu

Source Code Status Test Cases
    Policy: public     Reviewed: 8    
40.00 sec    7584 KB    30 lines     784 bytes    2017-05-20 04:15
drc = [(0, 1), (1, 0)]


def dfs(r, c):
    ret = []
    for dr, dc in drc:
        nr, nc = r + dr, c + dc
        if nr < H and nc < W and board[nr][nc].isdigit():
            cand = dfs(nr, nc)
            if len(cand) > len(ret) or (len(cand) == len(ret) and cand > ret):
                ret = cand
    return [board[r][c]] + ret


while True:
    W, H = map(int, input().split())
    if not (W | H):
        break
    board = [input() for _ in range(H)]
    ans = ''
    for r in range(H):
        for c in range(W):
            if board[r][c].isdigit() and board[r][c] != '0':
                cand = ''.join(dfs(r, c))
                # print(cand)
                if len(cand) > len(ans) or (len(cand) == len(ans) and cand > ans):
                    ans = cand
    print(ans)


Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 0/1 Python3 CPU: 40.00 sec Memory: 7584 KB Length: 784 B 2017-05-20 04:15 2017-05-20 04:16
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Time Limit Exceeded 20.00 sec 7584 KB
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags