当前位置: 代码迷 >> 综合 >> CCF 201604-2 俄罗斯方块 python 满分
  详细解决方案

CCF 201604-2 俄罗斯方块 python 满分

热度:68   发布时间:2024-02-23 18:23:39.0

CCF 201604-2 俄罗斯方块 python 满分

  • 题目叙述
    • 问题描述:略
    • 输入格式:略
    • 输出格式:略
    • 样例
  • 满分证明
  • 解题思路
  • 满分代码

题目叙述

问题描述:略

输入格式:略

输出格式:略

样例

样例输入
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0 0
1 1 1 0 0 0 1 1 1 1
0 0 0 0 1 0 0 0 0 0
0 0 0 0
0 1 1 1
0 0 0 1
0 0 0 0
3
样例输出
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0 0
1 1 1 1 1 1 1 1 1 1
0 0 0 0 1 1 0 0 0 0#我自己补充了一个作为验证
#=================
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 0 1 0 0
0 0 0 0 1 0 1 0 0 0
0 0 0 0 1 0 1 0 0 0
0 0 0 0 1 0 1 1 1 1
0 0 0 0 1 0 0 0 0 0
0 0 0 1
0 0 0 1
0 0 0 1
0 0 0 1
3

满分证明

在这里插入图片描述

解题思路

  1. 模拟下落过程,出现2则冲突,保留上一个结果;
  2. 注意下落模块,不全是1;
  3. 所以拓展原本矩阵。

满分代码

mb = [list(map(int, input().split())) for _ in range(15)]
bk = [list(map(int, input().split())) for _ in range(4)]
n = int(input())
# 扩增下面三行
for g in range(3):mb.insert(len(mb), [0] * 10)
# 避免下落不到位
jccs = 12
for j in range(4):if sum(bk[3 - j]) == 0:jccs += 1else:break# 判断合理
def Ishl(pmb, bk):res = [[0] * 4 for _ in range(4)]for i in range(4):for j in range(4):res[i][j] = pmb[i][j] + bk[i][j]for k in range(4):if 2 in res[3 - k]:return False, reselse:continuereturn True, restq = 0
tre = [[0] * 4 for _ in range(4)]
for u in range(jccs):dd = [l[n - 1:n + 3] for l in mb[u: u + 4]]flag, re = Ishl(dd, bk)if flag:tq = utre = reelse:break
# 修改原始矩阵值
for c in range(4):mb[tq:tq + 4][c][n - 1:n + 3] = tre[c]# break
for o in range(15):for p in range(10):print(mb[o][p], end=" ")print()
  相关解决方案