QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#486820 | #1819. Cleaning Robot | e | RE | 0ms | 0kb | Python3 | 1.3kb | 2024-07-22 04:18:50 | 2024-07-22 04:18:51 |
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)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
10 7 1 8 3