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: Runtime Error

Solution code:
from decimal import *
import numpy as np
getcontext().prec = 50
a, b, c = map(int, input().split())
tmp1 = Decimal(np.sqrt(a)) + Decimal(np.sqrt(b))
tmp2 = Decimal(np.sqrt(c))

if tmp1 < tmp2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  
  rep(i,n){
    string s = "";
    bitset<10> b(i);
    rep(j,n){
      if(b[n-j-1] == 0)s+="a";
      else s+="b";
    }
    cout<<s<<endl;
  }
  
  return 0;
}

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
	queue<string> q; q.push("a");
	int cnt = 1;
	while(cnt<n){
		rep(i,pow(2,cnt-1)){
			string tmp = q.front(); q.pop();
			char last = tmp[cnt-1];
			string f,s; f = tmp+last;
			last+=1; s=tmp+last;
			q.push(f); q.push(s);
		}
		cnt++;
	}
	rep(i,pow(2,cnt-1)){
		cout << q.front() << endl;
		q.pop();
	}

  return 0;
}

Submission status: Runtime Error

Solution code:
import copy
N = int(input())

L = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

ans = []

def f(List):
    if sum(List) == N:
        List.sort(reverse=True)
        s = ""
        for i in range(10):
            s += L[i]*List[i]
        ans.append(s)
    for i in range(9):
        if List[i+1] == 0:
            n = List[i]
            idx = i+1
            break
    for i in range(1, min(n, N-sum(List))+1):
        List2 = copy.copy(List)
        List2[idx] = i
        f(List2)

for i in range(1, N+1):
    List = [0]*10
    List[0] = i
    f(List)

ans.sort()
for a in ans:
    print(a)

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())

if b > a:
    temp = a
    a = b
    b = temp

res = c - a
res = res - b
temp = 4*a*b

if res**2 > temp:
    print ("Yes")
else:
    print ("No")

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
if a+b-c<2*(a*b)**0.5:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from decimal import *
getcontext().prec = 10000

a, b, c = list(map(int, input().split()))
aa = Decimal(a).sqrt()
bb = Decimal(b).sqrt()
cc = Decimal(c).sqrt()
d = c - a - b -Decimal(2)*aa*bb
print(d)

if d > 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli use[20];

lli n;

set<string> ans;
void func(string s,lli now,char before){
	if(now==n){
		cout<<s<<endl;
		//ans.insert(s);
		return;
	}
	lli nowIndex = before-'a';
	REP(i,0,nowIndex+2){
		func(s+(char)('a'+i),now+1,(char)('a'+i));
	}
}

signed main(){

	cin>>n;

	string s="a";
	func(s,1,'a');

	/*
	cout<<endl;
	for(auto e:ans){
		cout<<e<<endl;
	}
	*/

	return 0;
}

Submission status: Runtime Error

Solution code:
import sys
import numpy as np


def main():
    a, b, c = map(int, input().split())
    if c <= b or c <= a:
        print("No")
        sys.exit(0)

    left = a + b
    right = c - 2*np.sqrt(a*b)
    if left < right:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n=int(input())
from collections import deque
d=deque()
e=deque()
d.append("a")

alpha=list("abcdefghijklmnopqrstuvwxyz")
dic={alpha[i]:i for i in range(26)}
for i in range(n-1):
    while d:
        x=d.popleft()
 
        for j in range(dic[(x[-1])]+2):
            e.append(x+alpha[int(j)])  
    d=e.copy()
    e=deque()
d=list(d)

if n==1:
    print("a")
else:
    d=sorted(d)
    for some in d:
        print(some)

Submission status: Runtime Error

Solution code:
n=int(input())
from collections import deque
d=deque()
e=deque()
d.append("a")

alpha=list("abcdefghijklmnopqrstuvwxyz")
dic={alpha[i]:i for i in range(26)}
for i in range(n-1):
    while d:
        x=d.popleft()
 
        for j in range(dic[(x[-1])]+2):
            e.append(x+alpha[int(j)])  
    d=e.copy()
    e=deque()
d=list(d)

if n==1:
    print("a")
else:
    for some in d:
        print(some)

Submission status: Runtime Error

Solution code:
n=int(input())
li=["a"]
alpha=["a","b","c","d","e","f","g","h","i","j"]
if n==1:
    print("a")
else:
    for i in range(n-1):
        ans=[]
        for j in range(len(li)):
            if len(set(li[j]))==1:
                ans.append(li[j]+"a")
                ans.append(li[j]+"b")
            else:
                for k in range(i+2):
                    ans.append(li[j]+alpha[k])
        li=ans
for i in range(len(ans)):
    print(ans[i])

Submission status: Runtime Error

Solution code:
# ret = []
N = int(input())
L = [[0]]
# ret.append(L.copy())

for _ in range(N - 1):
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    L = newL.copy()
    
di = {i: chr(ord('a') + i) for i in range(10)}
print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))

Submission status: Runtime Error

Solution code:
l = ["a","b","c","d","e","f","g","i","j","k"]
n = int(input())
ans = [[] for i in range(n)]
ans[0].append("a")

for i in range(1,n):
    for j in ans[i-1]:
        for k in range(ord(j[-1])-ord("a")+2):
            an = j + l[k]
            ans[i].append(an)
count = ans[-1]
count.sort()
for i in count:
    print(i)

Submission status: Runtime Error

Solution code:
# ret = []
N = int(input())
L = [[0]]
ret.append(L.copy())

for _ in range(N - 1):
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    L = newL.copy()
    

print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

void go(string s, int mx, int n, vector<string>& ans) {
	if (n == 0) {
		ans.push_back(s);
		return;
	}
	for (int i = 0; i <= mx; ++i) {
		go(s + char('a' + i), max(mx, i + 1), n - 1, ans);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> ans;
	go("", 0, n, ans);
	for (auto& s: ans) {
		cout << s << endl;
	}
}

Submission status: Runtime Error

Solution code:
def main():

    H, W = map(int, input().split())
    ans = 0
    if W % 2 == 0 and H % 2 == 0:
        return (W//2) * (H//2) + (W//2) * (H//2)
    if W % 2 == 1 and H % 2 == 0:
        return ((W+1)//2) * (H//2) + (W//2) * (H//2)
    if W % 2 == 0 and H % 2 == 1:
        return (W//2) * ((H+1)//2) + (W//2) * (H//2)
    if W % 2 == 1 and H % 2 == 1:
        return ((W+1)//2) * ((H+1)//2) + (W//2) * (H//2)

if __name__ == '__main__':
    print(main())

Submission status: Runtime Error

Solution code:
import math

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    print(solve())


def solve():
    a, b, c = map(int, input().split())

    ra = math.sqrt(a)
    rb = math.sqrt(b)

    return ['No', 'Yes'][a + b + 2 * ra * rb < c]


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from itertools import product
N=int(input())
s="abcdefghij"
a
ab
abc
abcd
for i in range(N):
  c=s[:i+1]
  for p in product(c,repeat=N-i):
    print(c+"".join(p))

Submission status: Runtime Error

Solution code:
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

void recurse(string& s, int i, int n, char c);

int main() {
	fast_cin();
	int n; cin >> n;
	string s(n, 'a');
	recurse(s, 0, n, 'a');
}

void recurse(string& s, int i, int n, char c) {
	if (i == n) {
		cout << s << '\n';
	} else {
		for (char letter = 'a'; letter < c; ++letter) {
			s[i] = letter;
			recurse(s, i + 1, n, c);
		}
		s[i] = c;
		recurse(s, i + 1, n, min(char(c + 1), 'z'));
	}
}

Submission status: Runtime Error

Solution code:
a = "1"
print "a"