TOPIC

WA. Eu sei o pq,mas n sei resolver. Alguma ajuda?

luis asked 11 months ago

n = int(input())
matriz = list()
for c in range(n + 1):
    linha = [int(i) for i in input().split()]
    matriz.append(linha[:])
for i in range(n):
    resp = ''
    for j in range(n):
        if matriz[i][j] == 1:
            if matriz[i][j + 1] == 1 or matriz[i + 1][j] == 1 or matriz[i + 1][j + 1] == 1:
                resp += 'S'
            else:
                resp += 'U'
        else:
            if matriz[i][j + 1] == 1 and matriz[i + 1][j] == 1:
                resp = 'S'
            elif matriz[i + 1][j] == 1 and matriz[i + 1][j + 1] :
                resp += 'S'
            elif matriz[i + 1][j + 1] == 1 and matriz[i][j + 1] == 1:
                resp = 'S'
            else:
                resp += 'U'
    print(resp)

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.