| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 146483 | 桂依然 | 扫雷游戏 | Python3 | Accepted | 59 MS | 4280 KB | 834 | 2026-01-28 21:57:18 |
# 读取输入 n, m = map(int, input().split()) grid = [list(input().strip()) for _ in range(n)] # 定义8个方向的偏移量 directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] # 遍历每个格子 for i in range(n): for j in range(m): if grid[i][j] == '*': # 是地雷,跳过 continue # 统计周围地雷数 count = 0 for dx, dy in directions: x = i + dx y = j + dy # 检查坐标是否在雷区内 if 0 <= x < n and 0 <= y < m: if grid[x][y] == '*': count += 1 # 更新格子为数字 grid[i][j] = str(count) # 输出结果 for row in grid: print(''.join(row))