1 条题解

  • 0
    @ 2026-8-11 21:49:03
    n, m, k = map(int, input().split())
    px = [-1, -1, 0, 1, 1, 1, 0, -1]
    py = [0, 1, 1, 1, 0, -1, -1, -1]
    mat = []
    
    for i in range(n):
        mat.append([0] * m)
        
    for i in range(k):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        mat[x][y] = -1
        for j in range(8):
            nx = x + px[j]
            ny = y + py[j]
            if (nx >= 0 and ny >= 0 and nx < n and ny < m):
                if (mat[nx][ny] != -1):
                    mat[nx][ny] += 1
    
    for i in range(n):
        for j in range(m):
            if (mat[i][j] == -1):
                print("B", end = " ")
            else:
                print(mat[i][j], end = " ")
        print()
            
        
        
    
    
    • 1

    [COCI 2025/2026 #2] 地雷 / Minesweeper

    信息

    ID
    12619
    时间
    5000ms
    内存
    512MiB
    难度
    10
    标签
    递交数
    2
    已通过
    2
    上传者