python实现
查看原帖
python实现
1391413
garaxy楼主2024/7/18 13:46
n, m, k = map(int, input().split())
m_list = [tuple(map(int, input().split())) for i in range(m)]
k_list = [tuple(map(int, input().split())) for j in range(k)]
n_list = [[False] * n for r in range(n)]

for t in m_list:
    x, y = t[0] - 1, t[1] - 1
    n_list[x][y] = True
    coo = [(x - 2, y), (x - 1, y - 1), (x - 1, y), (x - 1, y + 1), (x, y - 2), (x, y - 1),
           (x + 2, y), (x + 1, y - 1), (x + 1, y), (x + 1, y + 1), (x, y + 2), (x, y + 1)]
    for i, j in coo:
        if 0 <= i < n and 0 <= j < n:
            n_list[i][j] = True

for t in k_list:
    x, y = t[0] - 3, t[1] - 3
    for i in range(5):
        for j in range(5):
            if 0 <= x + i < n and 0 <= y + j < n:
                n_list[x + i][y + j] = True

c = 0
for t in n_list:
    c += t.count(False)
print(c)
2024/7/18 13:46
加载中...