QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#486820#1819. Cleaning RoboteRE 0ms0kbPython31.3kb2024-07-22 04:18:502024-07-22 04:18:51

Judging History

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

  • [2024-07-22 04:18:51]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-22 04:18:50]
  • 提交

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
print(right if possible(right) else left if possible(left) else 0)

詳細信息

Test #1:

score: 0
Dangerous Syscalls

input:

10 7 1
8 3

output:


result: