412C - Pattern - CodeForces Solution


implementation strings *1200

Please click on ads to support us..

Python Code:

n = int(input())
res_pattern = ''
for i in range(n):
    pattern = input()
    if i == 0:
        res_pattern = list(pattern)
        question_marks = [0] * len(res_pattern)
    for j in range(len(pattern)):
        if res_pattern[j] != pattern[j]:
            if res_pattern[j] == "?":
                res_pattern[j] = pattern[j]
            elif pattern[j] == "?":
                continue
            else:
                res_pattern[j] = "1"
        else:
            if res_pattern[j] == "?":
                question_marks[j] += 1

for k in range(len(res_pattern)):
    if res_pattern[k] == "1":
        res_pattern[k] = "?"
    if question_marks[k] == n:
        res_pattern[k] = "x"
print("".join(res_pattern))
            


Comments

Submit
0 Comments
More Questions

1660A - Vasya and Coins
1660E - Matrix and Shifts
1293B - JOE is on TV
1584A - Mathematical Addition
1660B - Vlad and Candies
1472C - Long Jumps
1293D - Aroma's Search
918A - Eleven
1237A - Balanced Rating Changes
1616A - Integer Diversity
1627B - Not Sitting
1663C - Pōja Verdon
1497A - Meximization
1633B - Minority
688B - Lovely Palindromes
66B - Petya and Countryside
1557B - Moamen and k-subarrays
540A - Combination Lock
1553C - Penalty
1474E - What Is It
1335B - Construct the String
1004B - Sonya and Exhibition
1397A - Juggling Letters
985C - Liebig's Barrels
115A - Party
746B - Decoding
1424G - Years
1663A - Who Tested
1073B - Vasya and Books
195B - After Training