Problem:


Score : 400 points

Problem Statement

In this problem, we only consider strings consisting of lowercase English letters.

Strings s and t are said to be isomorphic when the following conditions are satisfied:

|s| = |t| holds.

For every pair i, j, one of the following holds:

s_i = s_j and t_i = t_j.

s_i \neq s_j and t_i \neq t_j.

For example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.

A string s is said to be in normal form when the following condition is satisfied:

For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison.

For example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.

You are given an integer N.
Print all strings of length N that are in normal form, in lexicographically ascending order.

Constraints

1 \leq N \leq 10

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Assume that there are K strings of length N that are in normal form: w_1, \ldots, w_K in lexicographical order.
Output should be in the following format:

w_1
:
w_K

Sample Input 1

1

Sample Output 1

a

Sample Input 2

2

Sample Output 2

aa
ab



Sample input:
1


Sample output:
a

Submission status: Wrong Answer

Solution code:
n = int(input())
alphabets = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]


def dfs(s):
    if len(s) == n:
        print(s)
    else:
        pre = "a"
        idx = 0
        for i, c in enumerate(list(s)):
            if pre < c:
                pre = c
                idx = i
        for i in range(idx + 2):
            dfs(s + alphabets[i])


dfs("a")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = ['a']
S = 'abcdefghij'
for _ in range(n-1):
    A = [ a + s for a in A for s in S[:len(a) + 1]]
print('\n'.join(A))

Submission status: Wrong Answer

Solution code:
import sys
import math

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [[-1] * N for _ in range(math.factorial(N))]
for i in range(math.factorial(N)):
    used = set()
    for j in range(1, N+1):
        for k in range((i%j)+1):
            if k not in used:
                A[i][j-1] = k
                used.add(k)
                break
        if A[i][j-1] == -1:
            A[i][j-1] = i%j
            used.add(i%j)

B = set()
for x in A:
    B.add(tuple(x))
A = sorted(list(B))
for x in A:
    x = [chr(y + ord('a')) for y in x]
    print(''.join(x))

Submission status: Wrong Answer

Solution code:
def saiki(s, n):
  if n == 0:
    print(s)
    return
  
  a = ord('a')
  c = ord(s[-1]) + 1
  
  
  for i in range(a, c+1):
    saiki(s+chr(i), n-1)
    
n = int(input())

saiki('a',n-1)

Submission status: Wrong Answer

Solution code:
N = int(input())


def dfs(s):
    if len(s) == N:
        print(s)
    else:
        for i in range(len(s)+1):
            dfs(s+chr(97+i))

dfs('a')

Submission status: Wrong Answer

Solution code:
N = int(input())

def dfs(n,i,s,ans):
    if n == N:
        ans.append(s)
        return
    
    for j in range(i+1):
        tmp = s + chr(j + 97)
        dfs(n+1,j+1,tmp,ans) 
    

def main():
    ans = []
    dfs(1,1,'a',ans)
    ans.sort()
    for a in ans:
        print(a)


    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
ABC=["A","B","C","D","E","F","G","H","I","J"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")

Submission status: Wrong Answer

Solution code:
import sys
import re

l = sys.stdin.readline()
l = int(l)
out = []
def x(stri,l,depth):
  str = 'abcdefghij'
  use = 0
  for i in range(0,l-depth+1):
    if( use == 1):
      break
    cdepth = depth
    cstri = stri
    if ( str[i] not in cstri):
      use = 1
    cstri += str[i] 
    cdepth -= 1
    if( cdepth == 0):
	out.append(cstri)
    else:
	x(cstri,l,cdepth)


stri = 'a'
if( l == 1):
 print stri
 exit(0)
x(stri,l,l-1)

ret = {}
count = 0
for i in out:
  prev = '0'
  moji = ""
  for j in i:
    if( prev == j ):
      moji += "E"
    else:
      if( prev > j ):
        moji += "U"
      else:
        moji += "D"
    prev = j
  ret[count] = moji
  count += 1
 
count = 0
kekka = {}
for i in out:
  if( ret[count] not in kekka.values()):
    print i
  kekka[count] = ret[count]
  count += 1


sys.stdout.flush()

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# a〜z -- START --
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
# a〜z --- END ---

n=I()

def dfs(x,s):
  if len(s)==n:
    print(s)
    return

  for i in range(x+1):
    _s=s+l[i]
    dfs(i+1,_s)

def main():
  dfs(0,'')

main()
# print(main())

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# a〜z -- START --
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
# a〜z --- END ---

n=I()

def dfs(x,s):
  if len(s)==n:
    print(s)
    return

  for i in range(x+1):
    _s=s+l[i]
    dfs(1,_s)

def main():
  dfs(0,'')

main()
# print(main())

Submission status: Wrong Answer

Solution code:

class Solution:

    def solve(self, N: int):

        def dfs(prev_str: str, max_used_char: str):
            if len(prev_str) == N:
                print(prev_str)
                return
            else:

                for i in range(ord('a'), ord(max_used_char) + 2):
                    c = chr(i)
                    if i == ord(max_used_char) + 1:
                        dfs(prev_str + c, max_used_char)
                    else:
                        dfs(prev_str + c, c)

        dfs('a', 'a')


if __name__ == '__main__':

    # standard input
    N=int(input())
    # solve
    solution=Solution()
    answer=solution.solve(N)

Submission status: Wrong Answer

Solution code:

class Solution:

    def solve(self, N: int):

        def dfs(prev_str: str, max_used_char: str):
            if len(prev_str) == N:
                print(prev_str)
                return
            else:

                for i in range(ord('a'), ord(max_used_char) + 2):
                    c = chr(i)
                    if i == ord(max_used_char) + 1:
                        dfs(prev_str + c, chr(i))
                    else:
                        dfs(prev_str + c, c)

        dfs('a', 'a')


if __name__ == '__main__':

    # standard input
    N = int(input())
    # solve
    solution = Solution()
    answer = solution.solve(N)

Submission status: Wrong Answer

Solution code:
N=int(input())

char="abcdefghijklmnopqrstuvwxyz"

def print_nth(base,n,prev_cnt):
    global char, N
    for i in range(n):
        if (i<=prev_cnt+1):
            str_n = base + char[i]
            if (n==N):
                print(str_n)
            elif (N>n):
                print_nth(str_n, n+1, i)

print_nth("",1,0)

Submission status: Wrong Answer

Solution code:
n = int(input())
L = []
def f(s):
    if len(s) == n:
        L.append(s)
        return
    for i in range(97, ord(s[-1])+2):
        f(s + chr(i))
f("a")
for l in L:
    print(l)

Submission status: Wrong Answer

Solution code:
N=int(input())

char="abcdefghijklmnopqrstuvwxyz"

def print_nth(base,n):
    global char, N
    for i in range(n):
        str_n = base + char[i]
        if (n==N):
            print(str_n)
        elif (N>n):
            print_nth(str_n, n+1)

print_nth("",1)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import itertools


def solve():
    N = int(input())

    if N==1:
        print("a")
        return

    base = ord("a")  # 97
    anss = []

    def _dfs(d, now, ans):
        if d==N:
            anss.append(ans)
            return

        for i in range(base, now+2):
            _dfs(d+1, i, ans+chr(i))

    _dfs(1, base, "a")

    anss.sort()

    for ans in anss:
        print(ans)


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n = int(input())

alphas = "abcdefghij"
init_str = ""

def standard(moji, x):
    if len(moji) == n:
        print(moji)
    else:
        for j in range(x):
            if j == x:
                standard(moji + alphas[j], i + 1)
            else:
                standard(moji + alphas[j], i)


standard(init_str, 0)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())

s = [[] for _ in range(N)]
a_ord = ord("a")

for i in range(N):
    if i == 0:
        s[0].append("a")
        continue
    for j in s[i - 1]:
        j_last_ord = ord(j[-1])
        for k in range(a_ord, j_last_ord + 2):
            s[i].append(j + chr(k))

ans = s[-1]
ans.sort()

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

min_char = "abcdefghij"

def dtype_tree(tree, start, num):
    for i in range(start+1):
        tgt_tree = [i]
        if num > 0:
            new_tree = dtype_tree([], i+1, num-1)
            tgt_tree.append(new_tree)

        if tree == None:
            tree = tgt_tree
        else:
            tree.append(tgt_tree)
    return tree

def print_tree(tree, prefix):
    new_prefix = prefix
    if len(tree) == 1:
        print(prefix + min_char[tree[0]])
    else:
        for elem in tree:
            if type(elem) != list:
                new_prefix += min_char[elem]
#                print(new_prefix)
            else:
                print_tree(elem, new_prefix)

    return


def abc_XXX(num):
    tree = dtype_tree(None, 0, num-1)
#    print(tree)
    print_tree(tree, "")
    return

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    
    abc_XXX(n)
    
    # output

# else:
    # do nothing

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():

    S = ["a"]
    N = int(input())

    def add_str(S):
        if len(S)==N:
            print("".join(S))
        else:
            for j in range(97,ord(S[-1])+2):
                add_str(S+[chr(j)])

    add_str(S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


N = int(input())
ans = []
a = ord('a')


def f(c, A):
    global N, a
    if 0 not in A:
        ans.append(''.join(A))
        return
    B = list(A)
    for i in range(2 ** (B.count(0)) - 1, 2 ** (B.count(0) - 1) - 1, -1):
        k = i
        C = B[:]
        idx = C.index(0)
        while k > 0:
            if k & 1 == 1:
                C[idx] = c
            if 0 in C[idx + 1:]:
                idx = C.index(0, idx + 1)
            k >>= 1
        f(chr(ord(c) + 1), tuple(C))



A = [0] * N
f('a', tuple(A))
ans = list(ans)
ans.sort()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
chars = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
N = int(input())

def solve(s = "", depth = 0):
  if len(s) == N:
    print(s)
    return
  
  for i in range(depth + 1):
    solve(s + chars[i], depth + 1)

solve()

Submission status: Wrong Answer

Solution code:
import copy

n = int(input())

ary_list = []
def f(ary, max_num):
    if len(ary) == n:
        ary_list.append(ary)
        return
    for i in range(max_num + 2):
        next_ary = copy.copy(ary)
        next_ary.append(i)
        f(next_ary, max_num + 1 if i == max_num + 1 else 0)

f([], -1)

str_list = []
for i in range(len(ary_list)):
    for j in range(n):
        ary_list[i][j] = chr(97 + ary_list[i][j])
    str_list.append("".join(ary_list[i]))

str_list = sorted(str_list)

for s in str_list:
    print(s)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
stack = collections.deque("a")
charset = [chr(ord("a") + i) for i in range(26)]
ans = []
while stack:
    s = stack.pop()
    if len(s) == N:
        ans.append(s)
        continue
    for i in range(charset.index(s[-1]) + 2):
        stack.append(s + charset[i])
[print(a) for a in sorted(ans)]

Submission status: Wrong Answer

Solution code:
import copy

n = int(input())

ary_list = []
def f(ary, max_num):
    if len(ary) == n:
        ary_list.append(ary)
        return
    for i in range(max_num + 2):
        next_ary = copy.copy(ary)
        next_ary.append(i)
        f(next_ary, max_num + 1 if i == max_num else 0)

f([], -1)

str_list = []
for i in range(len(ary_list)):
    for j in range(n):
        ary_list[i][j] = chr(97 + ary_list[i][j])
    str_list.append("".join(ary_list[i]))

str_list = sorted(str_list)

for s in str_list:
    print(s)

Submission status: Wrong Answer

Solution code:
import copy

n = int(input())

ary_list = []
def f(ary, max_num):
    if len(ary) == n:
        ary_list.append(ary)
        return
    for i in range(max_num + 1):
        next_ary = copy.copy(ary)
        next_ary.append(i)
        f(next_ary, max_num + 1 if i == max_num else 0)

f([], 0)

str_list = []
for i in range(len(ary_list)):
    for j in range(n):
        ary_list[i][j] = chr(97 + ary_list[i][j])
    str_list.append("".join(ary_list[i]))

str_list = sorted(str_list)

for s in str_list:
    print(s)

Submission status: Wrong Answer

Solution code:
import copy

n = int(input())

ary_list = []
def f(ary, max_num):
    if len(ary) == n:
        ary_list.append(ary)
        return
    for i in range(max_num + 1):
        next_ary = copy.copy(ary)
        next_ary.append(i)
        f(next_ary, max_num + 1 if i == max_num else 0)

f([], 0)
ary_list

str_list = []
for i in range(len(ary_list)):
    for j in range(n):
        ary_list[i][j] = chr(97 + ary_list[i][j])
    str_list.append("".join(ary_list[i]))

str_list = sorted(str_list)

for s in str_list:
    print(s)

Submission status: Wrong Answer

Solution code:
def dfs(word, i):
    if len(word) == n:
        print(word)
    else:
        if i == 0:
            dfs(word + chr(97), 1)
        else:
            for j in range(i+1):
                if j != i:
                    dfs(word + chr(97 + j), j)
                else:
                    dfs(word + chr(97 + j), j+1)


if __name__ == "__main__":
    n = int(input())

    dfs('', 0)

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

strlist = "abcdefghij"

def dfs(s,num):
    if len(s) == n:
        print(s)
        return
    elif num ==0:
        dfs("a",1)
    else:
        for i in range(num):
            dfs(s+strlist[i],num+1)
        dfs(s+strlist[num],num+1)

dfs("",0)

Submission status: Wrong Answer

Solution code:
import itertools

def resolve():
    n = int(input())
    l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

    init = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']
    print(''.join(init[0:n]))
    for str in itertools.combinations_with_replacement(l[0:n], n):
        if len(list(set(str))) != 1:
            print(''.join(str))
            
resolve()

Submission status: Wrong Answer

Solution code:
def d_string_equivalence():
    from itertools import product
    N = int(input())

    ans = ['a' + ''.join(s) for s in product('ab', repeat=N - 1)]
    return '\n'.join(ans)

print(d_string_equivalence())

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    n -= 1
    now = ['a']
    for _ in range(n):
        next = []
        for S in now:
            d = ord(min(S)) - ord('a')
            for i in range(d+2):
                next.append(S + chr(i + ord('a')))
        now = next

    now.sort()
    for S in now:
        print(S)
resolve()

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

strlist = "abcdefghij"

def dfs(s,num):
    if len(s) == n:
        print(s)
    elif num ==0:
        dfs("a",1)
    else:
        for i in range(num+1):
            dfs(s+strlist[i],num+1)

dfs("",0)

Submission status: Wrong Answer

Solution code:
def dfs(word, n):
    if len(word) == l:
        print(word)
    else:
        for i in range(n+1):
            dfs(word + chr(97 + i), i+1)


if __name__ == "__main__":
    l = int(input())

    dfs('', 0)

Submission status: Wrong Answer

Solution code:
n=int(input())
dic={0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j'}
ans=[['a',1]]
for i in range(1,n):
  tmp=[]
  for prev,val in ans:
    for j in range(val+1):
      if j!=val:
        tmp.append([prev+dic[j],val])
      else:
        tmp.append([prev+dic[j],val+1])
  ans=tmp
ans=sorted(ans,key=lambda x:x[0])
print(len(ans))
for i in range(len(ans)):
  print(ans[i][0])

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    n = int(input())
    r = lambda n: [''] if n <= 0 else [e + j for e in r(n - 1) for j in [chr(ord('a') + e) for e in range(n)]]
    a = r(n)
    for e in a:
        print(e)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = int(input())
    r = lambda n: [''] if n <= 0 else [e + j for e in r(n - 1) for j in [chr(ord('a') + e) for e in range(n)]]
    a = r(n)
    print(a)

Submission status: Wrong Answer

Solution code:
def dfs(word, n):
    if len(word) == l:
        print(word)
    else:
        for i in range(n+1):
            dfs(word + chr(97 + i), n+1)


if __name__ == "__main__":
    l = int(input())

    dfs('', 0)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[]
def dfs(s,st):
  if len(s)==n:
    ans.append(s)
    return 
  else:
    for i in range(ord('a'),ord(st)+1):
      dfs(s+chr(i),chr(i+1))
dfs('','a')
ans.sort()
for x in ans:
  print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
candidate = ['a']


def dfs(s, c):
    if len(s) == n:
        return
    candidate.append(s + c)
    candidate.append(s + chr(ord(c) + 1))
    dfs(s + c, c)
    dfs(s + chr(ord(c) + 1), chr(ord(c) + 1))


dfs('a', 'a')

for c in candidate:
    if len(c) == n:
        print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
from collections import deque
import itertools
ans = deque()
l = []
r = deque()
for i in range(N):
  l.append(chr(97+i))
  r.append(l.copy())
  

p = [[[] for _ in range(N)] for _ in range(N)]
p[0][0].append('a')
for i in range(1,N):
  for j in r[i]:
    x = ord(j)-97
    for n,k in enumerate(p[i-1][max(0,x-1):],max(0,x-1)):
      for m in k:
        p[i][max(n,x)].append(m+j)


p = p[-1]
for i,q in enumerate(p):
  q = sorted(q)
  p[i]=q
p = list(itertools.chain.from_iterable(p))
for q in p:
  print(q)

Submission status: Wrong Answer

Solution code:
import math
import sys
import copy

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N = ni()

def dp(n,max):
    # print("dp",n,max)
    if max <=0: 
        return []
    if max > n:
        return s[n][n]
    else:
        return s[n][max]

def dp2(n,max):
    # print("dp",n,max)
    if max <=0: 
        return []
    if max > n:
        max = n 
    ans = copy.copy(s[n][0])
    for i in range(1,max+1):
        ans. extend(s[n][i])
    return ans

# print(N)
s= [[[[]]],[[],[[1]]]]
# print(s)
for i in range(2,N+1):
    si = [[]]
    for j in range(1,i+1):
        # print(i,j)
        jk = j - 1
        sj = []
        # print('sj',sj)
        # print('S',dp2(i-j,j))
        for c in dp2(i-j,j):
            # print('C',c)
            list = [j]
            list.extend(c)
            # print(list)
            sj.append(list)
        si.append(sj)
    # print("si",si)
    s.append(si)
    # print(s)

def output(s):
    x = []
    alpha='abcdefghijklmnop'
    out=[]
    for i in range(len(s)):
        for j in range(s[i]):
            out.append(alpha[i])
    x.append(''.join(out))
    x.sort()
    for k in x:
        print(k)


for i in range(N,0,-1):
    m = len(s[N][i])
    for j in range(m-1,-1,-1):
        output(s[N][i][j])

Submission status: Wrong Answer

Solution code:
import math
import sys
import copy

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N = ni()

def dp(n,max):
    # print("dp",n,max)
    if max <=0: 
        return []
    if max > n:
        return s[n][n]
    else:
        return s[n][max]

def dp2(n,max):
    # print("dp",n,max)
    if max <=0: 
        return []
    if max > n:
        max = n 
    ans = copy.copy(s[n][0])
    for i in range(1,max+1):
        ans. extend(s[n][i])
    return ans

# print(N)
s= [[[[]]],[[],[[1]]]]
# print(s)
for i in range(2,N+1):
    si = [[]]
    for j in range(1,i+1):
        # print(i,j)
        jk = j - 1
        sj = []
        # print('sj',sj)
        # print('S',dp2(i-j,j))
        for c in dp2(i-j,j):
            # print('C',c)
            list = [j]
            list.extend(c)
            # print(list)
            sj.append(list)
        si.append(sj)
    # print("si",si)
    s.append(si)
    # print(s)

def output(s):
    alpha='abcdefghijklmnop'
    out=[]
    for i in range(len(s)):
        for j in range(s[i]):
            out.append(alpha[i])
    print(''.join(out))


for i in range(N,0,-1):
    m = len(s[N][i])
    for j in range(m-1,-1,-1):
        output(s[N][i][j])

Submission status: Wrong Answer

Solution code:
n=int(input())
def dfs(s,st):
  if len(s)==n:
    return print(s)
  else:
    for i in range(ord('a'),ord(st)+1):
      dfs(s+chr(i),chr(i+1))
dfs('','a')

Submission status: Wrong Answer

Solution code:
import sys

N=int(input())
def num2alpha(num):
    return chr(97+num)
print(''.join(['a']*N))
for i in range(N-1):
  a=['0']*N
  while True:
    a=[j for j in str(int(''.join(a))+1).zfill(N)]
    print(''.join([num2alpha(int(i)) for i in a]))   
    
    if a[N-i-1]>max(a[:N-i-1]):
      break

Submission status: Wrong Answer

Solution code:
def saiki(s, n):
  if n == 0:
    print(s)
    return
  
  next_c = chr(ord(s[-1])+1)
  saiki(s+s[-1], n-1)
  saiki(s+next_c, n-1)

n = int(input())

saiki('a',n-1)

Submission status: Wrong Answer

Solution code:
import sys

N=int(input())
def num2alpha(num):
    return chr(97+num)
print(''.join(['a']*N))
for i in range(N-1):
  a=['0']*N
  while True:
    a=[i for i in str(int(''.join(a))+1).zfill(N)]
    print(''.join([num2alpha(int(i)) for i in a]))   
    
    if a[N-i-1]>max(a[:N-i-1]):
      break

Submission status: Wrong Answer

Solution code:
import string
n = int(input())
cs = string.ascii_lowercase
cm = {cs[i]:i for i in range(len(cs))}
t = 1
def rec(st):
    global t
    if (len(st) >= n):
        print(t, ":", st)
        t += 1
        return 0
    k = max(cm[st[i]]+1 for i in range(len(st)))
    for c in cs[: k + 1]:
        rec(st+c)
    
    
rec('a')

Submission status: Wrong Answer

Solution code:
import sys

N=int(input())
def num2alpha(num):
    return chr(97+num)
  
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out
print(''.join(['a']*N))
for i in range(N-1):
  a=['0']*N
  while True:
    temp=Base_10_to_n(Base_n_to_10(''.join(a),5)+1,N).zfill(N)
    a=[i for i in temp]
    print(''.join([num2alpha(int(i)) for i in a]))   
    #sys.exit()
    b=True
    for j in range(N-i-1):
      if a[N-i-1]>a[j]:
        b=False
        break
    if not b:
      break

Submission status: Wrong Answer

Solution code:
#a,b,c = [int(x) for x in input().split()]
n = int(input())
l = [0]*n
ans = ""
al=["a","b","c","d","e","f","g","h","i","j"]
if n == 1:
  print("a")
elif n == 2:
  for x in range(2):
    l[1] = x
    for i in range(n):
      for k in range(n):
        if l[i] == k:
          ans = ans + al[k]
    print(ans)
    ans = ""
elif n == 3:
  for x in range(2):
    l[1] = x
    for a in range(l[1]+2):
      l[2] = a
      for i in range(n):
        for k in range(n):
          if l[i] == k:
            ans = ans + al[k]
      print(ans)
      ans = ""
elif n == 4:
  for x in range(2):
    l[1] = x
    for a in range(l[1]+2):
      l[2] = a
      for b in range(l[2]+2):
        l[3] = b
        for i in range(n):
          for k in range(n):
            if l[i] == k:
              ans = ans + al[k]
        print(ans)
        ans = ""
elif n == 5:
  for x in range(2):
    l[1] = x
    for a in range(l[1]+2):
      l[2] = a
      for b in range(l[2]+2):
        l[3] = b
        for c in range(l[3]+2):
          l[4] = c        
          for i in range(n):
            for k in range(n):
              if l[i] == k:
                ans = ans + al[k]
          print(ans)
          ans = ""
elif n == 6:
  for x in range(2):
    l[1] = x
    for a in range(l[1]+2):
      l[2] = a
      for b in range(l[2]+2):
        l[3] = b
        for c in range(l[3]+2):
          l[4] = c
          for d in range(l[4]+2):
            l[5] = d
            for i in range(n):
              for k in range(n):
                if l[i] == k:
                  ans = ans + al[k]
            print(ans)
            ans = ""
            
elif n == 7:
  for x in range(2):
    l[1] = x
    for a in range(l[1]+2):
      l[2] = a
      for b in range(l[2]+2):
        l[3] = b
        for c in range(l[3]+2):
          l[4] = c
          for d in range(l[4]+2):
            l[5] = d
            for e in range(l[5]+2):
              l[6] = e          
              for i in range(n):
                for k in range(n):
                  if l[i] == k:
                    ans = ans + al[k]
              print(ans)
              ans = ""
elif n == 8:
  for x in range(2):
    l[1] = x
    for a in range(l[1]+2):
      l[2] = a
      for b in range(l[2]+2):
        l[3] = b
        for c in range(l[3]+2):
          l[4] = c
          for d in range(l[4]+2):
            l[5] = d
            for e in range(l[5]+2):
              l[6] = e
              for f in range(l[6]+2):
                l[7] = f         
                for i in range(n):
                  for k in range(n):
                    if l[i] == k:
                      ans = ans + al[k]
                print(ans)
                ans = "" 
elif n == 9:
  for x in range(2):
    l[1] = x
    for a in range(l[1]+2):
      l[2] = a
      for b in range(l[2]+2):
        l[3] = b
        for c in range(l[3]+2):
          l[4] = c
          for d in range(l[4]+2):
            l[5] = d
            for e in range(l[5]+2):
              l[6] = e
              for f in range(l[6]+2):
                l[7] = f
                for g in range(l[7]+2):
                  l[8] = g   
                  for i in range(n):
                    for k in range(n):
                      if l[i] == k:
                        ans = ans + al[k]
                  print(ans)
                  ans = ""                          
elif n == 10:
  for x in range(2):
    l[1] = x
    for a in range(l[1]+2):
      l[2] = a
      for b in range(l[2]+2):
        l[3] = b
        for c in range(l[3]+2):
          l[4] = c
          for d in range(l[4]+2):
            l[5] = d
            for e in range(l[5]+2):
              l[6] = e
              for f in range(l[6]+2):
                l[7] = f
                for g in range(l[7]+2):
                  l[8] = g
                  for h in range(l[8]+2):
                    l[9] = h         
                    for i in range(n):
                      for k in range(n):
                        if l[i] == k:
                          ans = ans + al[k]
                    print(ans)
                    ans = ""

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# 同型→文字数カウントのパターンが同じ
# 標準形→文字数辞書順の最も速いもの


N = read_a_int()


moji = 'abcdefghij'
candi = []
moji = moji[:N]


def dfs(now, i, j):
    # j....一つ前の文字のidx(どこまで見たか)
    # 文字を作って返す
    if i == N:
        candi.append(now)
        return
        # return now
    for jj in range(j + 2):
        dfs(now + moji[jj], i + 1, jj)


dfs('', 0, -1)

print(*candi, sep='\n')


# for i in range(1, N + 1):  # 何番目まで使うか
#     mojisyu = moji[:i]  # ここで使う文字種類
#     # 文字種類でaを先頭にできるだけ標準形を列挙したい
#     for j in range(1, i):

Submission status: Wrong Answer

Solution code:
N=int(input())

S = 'abcdefghij'

def num(x):
    ans = 0
    for i in range(len(S)):
        count = 0
        for j in range(0,len(x)):
            if x[j] == S[i]:
                count = count +1
        if count != 0:
            ans = ans + 1
        else:
            ans = ans
    return ans

def base(x):
    List=[]
    for j in range(len(x)):
        for i in range(num(x[j])+1):
            List.append(x[j]+S[i])
    return List

K = 'a'

cou = 1
while cou < N:
    K = base(K)
    cou = cou+1

print(K)

Submission status: Wrong Answer

Solution code:
s = 'a'
n = int(input())
res = []
def rec(s, add):
    s += add
    if len(s) == n:
        res.append(s)
        return s
    rec(s, 'a')
    rec(s, 'b')
    
rec(s, '')
for i in range(n):
    print(res[i])