QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#486819#1819. Cleaning RoboteCompile Error//Python31.3kb2024-07-22 04:17:482024-07-22 04:17:48

Judging History

你现在查看的是最新测评结果

  • [2024-07-22 04:17:48]
  • 评测
  • [2024-07-22 04:17:48]
  • 提交

answer

n, m, k = [int(_) for _ in input().split()]
xys = [[0] * (m + 1) for i in range(n + 1)]
for i in range(k):
    x, y = [int(a) for a in input().split()]
    xys[x][y] = 1
for i in range(1, n + 1):
    for j in range(1, m + 1):
        xys[i][j] += xys[i - 1][j] + xys[i][j - 1] - xys[i - 1][j - 1]
left, right = 1, min(n, m)

def possible(s):
    flag = False
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if xys[i + s - 1][j + s - 1] - xys[i + s - 1][j - 1] - xys[i - 1][j + s - 1] + xys[i - 1][j - 1] == 0:
                dq = deque([[i, j]])
                seen = {(i, j)}
                flag = True
                break
        if flag:
            break
    if flag:
        while dq:
            x, y = dq.popleft()
            for nx, ny in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]:
                if 0 < nx <= n + 1 and 0 < ny <= m + 1 and (nx, ny) not in seen and xys[nx + s - 1][ny + s - 1] - xys[nx + s - 1][ny - 1] - xys[nx - 1][ny + s - 1] + xys[nx - 1][ny - 1] == 0:
                    dq.append([nx, ny])
                    seen.add((nx, ny))
        return len(seen) == n * m - k

while left + 1 < right:
    mid = (left + right) // 2
    if possible(mid):
        left = mid
    else:
        right = mid
return rigth if possible(right) else left if possible(left) else 0

詳細信息

  File "answer.code", line 37
    return rigth if possible(right) else left if possible(left) else 0
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'return' outside function