Участник:StasFomin/Solutions/codechef/CHTPNDMC

Материал из DISCOPAL
Перейти к: навигация, поиск
import numpy as np
 
def solver():
    N = int(input())
    m = np.eye(N, dtype = str)
    in_string = input()
    out_string = input()
    for i in range(N):
        counter = 1
        j = i
        while j >= 0:
            if i == j:
                m[i][j] = 'Y'
            else:
                if in_string[j] == 'Y' and out_string[j + 1] == 'Y' and counter == 1:
                    m[i][j] = 'Y'
                else: 
                    m[i][j] = 'N'
                    counter = 0
            j -= 1        
        counter = 1
        for j in range(i + 1, N):
            if in_string[j] == 'Y' and out_string[j - 1] == 'Y' and counter == 1:
                m[i][j] = 'Y'
            else: 
                m[i][j] = 'N'
                counter = 0
    for i in range(N):
        print(*m[i], sep ='')
 
T = int(input())
for i in range(T):
    print(f"Case #{i+1}:")
    solver()