#41814: 答案 (python)


Morrischen (morris)

學校 : 高雄市苓雅區復華高級中學國中部
編號 : 236381
來源 : [111.184.105.175]
最後登入時間 :
2024-10-19 19:13:51
n130. p2. 製作看板 -- 110新北市資訊學科能力複賽 | From: [163.16.248.157] | 發表日期 : 2024-08-29 08:32

#n130. p2. 製作看板|
r,c    = map(int, input().split())
w      = [i for i in input()]
maze   = [[i for i in input()] for _ in range(r)]
_count = sum([i.count(".") for i in maze])
total = (_count-len(w))//2
for R in range(r):
    for C in range(c):
        if maze[R][C]==".":
            if total ==0:
                if len(w)!=0:
                    a          = w.pop(0)
                    maze[R][C] = a
            else:
                total-=1
for R in range(r):
    for C in range(c):
        print(maze[R][C],end ="")
    print("")

 
ZeroJudge Forum