Special Characters (Codeforces 1948A)
Tags: Others, brute force

You are given an integer $$$n$$$.Your task is to build a string of uppercase Latin letters. There must be exactly $$$n$$$ special characters in this string. Let's call a character special if it is equal to exactly one of its neighbors.For example, there are $$$6$$$ special characters in the AAABAACC string (at positions: $$$1$$$, $$$3$$$, $$$5$$$, $$$6$$$, $$$7$$$ and $$$8$$$).Print any suitable string or report that there is no such string.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 50$$$) — the number of test cases.The only line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 50$$$).

Output: For each test case, print the answer as follows:   if there is no suitable string, print one line containing the string NO;  otherwise, print two lines. The first line should contain the string YES; on the second line print a string of length at most $$$200$$$ — the answer itself (it can be shown that if some answers exist, then there is an answer of length at most $$$200$$$). If there are several solutions, print any of them. 


Sample Inputs:
3
6
1
2

Sample Outputs:
YES
AAABAACC
NO
YES
MM

Solution (Python):
n = int(input())
simbols = []
for i in range(n):
    simbol = int(input())
    simbols.append(simbol)
for j in range(n):
    if simbols[j] % 2 != 0:
        print('NO')
    else:
        print('YES')
        while simbols[j] > 0:
            print('AA', end='')
            if simbols[j] != 2:
                print('B', end='')
            simbols[j] -= 2
        print()

Solution (Python):
def x():
    n = int(input())
    if n % 2:
        print('NO')
        return
    else:
        print('YES')
        print('AAB' * (n // 2))
        return
t = int(input())
for _ in range(t):
    x()

Solution (Python):
import sys
cases = int(sys.stdin.readline())
for case in range(cases):
    n = int(sys.stdin.readline())
    if n % 2 == 0:
        letter = 65
        output = ''
        print('YES')
        for _ in range(int(n / 2)):
            output = output + 2 * chr(letter)
            letter += 1
        print(output)
    else:
        print('NO')