python答案对的但是全都RE,估计是输入有问题,有大佬帮忙看看怎么改吗谢了
查看原帖
python答案对的但是全都RE,估计是输入有问题,有大佬帮忙看看怎么改吗谢了
1231862
lzysxfcs楼主2024/4/11 22:38
matrix = []  #储存图阵
while True:
    row = input()
    if row:
        matrix.append(row)
    else:
        break
matrix1 = ''.join(matrix) + 'x'
N = len(matrix[0])
code = []  #储存压缩码
code.append(N)
count =1
for index,char in enumerate(matrix1[:-1]):
    if char == matrix1[index+1]:
        count +=1
    else:
        code.append(count)
        count =1
result = ' '.join(map(str,code))
print(result)
2024/4/11 22:38
加载中...