40 lines
981 B
Python
40 lines
981 B
Python
from typing import Tuple, List
|
|
import math
|
|
|
|
n, m, r = map(int, input().split())
|
|
locations: List[Tuple[int, int]] = []
|
|
|
|
for i in range(m):
|
|
x, y = map(int, input().split())
|
|
# 将输入的1-based坐标转换为0-based坐标
|
|
locations.append((x - 1, y - 1))
|
|
|
|
grid = [[0 for _ in range(n)] for _ in range(n)]
|
|
count = 0
|
|
|
|
for location in locations:
|
|
x, y = location
|
|
if grid[x][y] != 1:
|
|
grid[x][y] = 1
|
|
count += 1
|
|
|
|
# 检查半径r内的所有点
|
|
left = max(0, x - r)
|
|
right = min(n, x + r + 1)
|
|
top = max(0, y - r)
|
|
bottom = min(n, y + r + 1)
|
|
|
|
for i in range(left, right):
|
|
for j in range(top, bottom):
|
|
# 计算点(i,j)到探测器(x,y)的距离
|
|
distance = math.sqrt((i - x) ** 2 + (j - y) ** 2)
|
|
if distance <= r: # 如果在探测范围内
|
|
if grid[i][j] != 1:
|
|
grid[i][j] = 1
|
|
count += 1
|
|
|
|
print(count)
|
|
for row in grid:
|
|
print(row)
|
|
|