唉,好久没有来更新了,最近真的超多事情。后天就要考CCF,虽然平时练的挺好,但是上了考场上完全不一样的感觉,没有灵光乍现的话,我这脑子真的说不定。加油吧,novice!好运
#消除类游戏
m,n = map(int,input().split())
check = []
for i in range(m):
check.append(list(map(int,input().split())))
ans = []
for i in check:
ans.append(i[:])
#先按行扫描check是否可消除ans
#再按列扫描check是否可消除ans
#行
for i in range(m):
j = 0
while j < n:
k = j+1
while k < n and check[i][k] == check[i][j]: #扫描到不匹配的元素停止
k += 1
if k - j >= 3: #下标之差就是相同的元素个数
ans[i][j:k] = [0] * (k-j)
j = k
#列
for i in range(n):
j = 0
while j < m:
k = j + 1
while k < m and check[k][i] == check[j][i]:
k += 1
if k-j >= 3:
for x in range(j,k):
ans[x][i] = 0
j = k
for i in ans:
for j in i:
print(j,end=' ')
print()
#火车购票
#火车购票
seats = [[True]+[False for i in range(5)] for j in range(20)] # 座位初始化时为未占用状态False,占用状态True
n = int(input()) # 购票指令的数量
order = list(map(int,input().split()))
ans = []
for i in order:
flag = False # 判断是否找到连续的座位
temp = []
j = 0
while j < 20:
if seats[j].count(False) >= i:
flag = True
k = 1
while k < 6 and i > 0:
if seats[j][k] == False:
seats[j][k] = True
i -= 1
temp.append(j*5+k) # 如果找到了连续的座位,则计算座位号
k += 1
ans.append(temp)
break
j += 1
if flag:
continue
j = 0
flag = False # 如果没有找到连续的座位号,就按行扫描,有空座位就坐
while j < 20:
for k in range(1,6):
if seats[j][k] == False:
seats[j][k] = True
i -= 1
temp.append(j*5+k)
if i == 0:
ans.append(temp)
flag = True
break
if flag:
break
j += 1
for i in ans:
for j in i:
print(j,end=' ')
print()