题解 | #小红炸砖块#
小红炸砖块
https://www.nowcoder.com/practice/2715e18a82a548c7b00c94a348df0b84
n, m, k = map(int, input().split())
t = [tuple(map(int, input().split())) for _ in range(k)]
# Initialize the grid with '*'
res = [['*'] * m for _ in range(n)]
# Record the next available row in each column
next_available_row = [0] * m
# Process each bomb
for x, y in t:
j = y - 1
i = next_available_row[j]
if i < x: # Ensure we don't go out of bounds
res[i][j] = '.'
next_available_row[j] += 1
# Print the resulting grid
for r in res:
print(''.join(r))
查看13道真题和解析
小天才公司福利 1159人发布