python运行全报RE

P5730 【深基5.例10】显示屏

lanxiong @ 2024-11-23 02:50:40

a = ['' for x in range(5)]
a[0] = 'XXX...X.XXX.XXX.X.X.XXX.XXX.XXX.XXX.XXX'
a[1] = 'X.X...X...X...X.X.X.X...X.....X.X.X.X.X'
a[2] = 'X.X...X.XXX.XXX.XXX.XXX.XXX...X.XXX.XXX'
a[3] = 'X.X...X.X.....X...X...X.X.X...X.X.X...X'
a[4] = 'XXX...X.XXX.XXX...X.XXX.XXX...X.XXX.XXX'

n = input()
m = input()
b = ['' for j in range(5)]
for x in range(len(m)):
    for y in range(5):
        z = int(m[x])
        b[y] += a[y][4*z:4*z+3] + '.'
for x in range(5):
    if x == 4:
        print(b[x][:-1], end='')
        break
    print(b[x][:-1])

俺寻思在我电脑上写出来运行没毛病呀,求大神帮忙看看哪里有问题


by lusers @ 2024-11-23 08:22:19

洛谷评测数据的换行符有的时候并不是 LF,而是 CRLF,所以 input() 就会多读进去一个 CR。

解决方法是:

n = input().strip()
m = input().strip()

by lusers @ 2024-11-23 08:22:54

@lanxiong


by lanxiong @ 2024-11-23 12:42:30

@lusers谢谢大佬,我明白了,昨晚也是在想是不是读到EOF啥的,也不能试试评测的文件,实在窘迫啊


|