Codeforces Beta Round 37
C
古伯兰语言
Old Berland Language
Codeforces
1900
原题
← BD →

古伯兰语言AI (CI翻译)

Berland scientists know that the Old Berland language had exactly $*n*$ words. Those words had lengths of $*l*_{1}, *l*_{2}, ..., *l*_{*n*}$ letters. Every word consisted of two letters, $0$ and $1$. Ancient Berland people spoke quickly and didn’t make pauses between the words, but at the same time they could always understand each other perfectly. It was possible because no word was a prefix of another one. The prefix of a string is considered to be one of its substrings that starts from the initial symbol.

Berland 的科学家知道,古伯兰语言恰好有 $*n*$ 个单词。这些单词的长度分别为 $*l*_{1}, *l*_{2}, ..., *l*_{*n*}$ 个字母。每个单词都只由 $0$ 和 $1$ 两种字母组成。古代 Berland 人说话很快,单词之间不会停顿,但他们总能彼此准确理解。这是因为没有一个单词是另一个单词的前缀。字符串的前缀是指从首字符开始的子串。AI (CI翻译)

Help the scientists determine whether all the words of the Old Berland language can be reconstructed and if they can, output the words themselves.

请帮助科学家判断能否还原古伯兰语言的所有单词;如果可以,请输出这些单词。AI (CI翻译)

Input

输入格式

AI (CI翻译)

The first line contains one integer $*N*$ ($1 ≤ *N* ≤ 1000$) — the number of words in Old Berland language. The second line contains $*N*$ space-separated integers — the lengths of these words. All the lengths are natural numbers not exceeding $1000$.

第一行包含一个整数 $*N*$($1 ≤ *N* ≤ 1000$),表示古伯兰语言中的单词数。第二行包含 $*N*$ 个以空格分隔的整数,表示这些单词的长度。所有长度均为不超过 $1000$ 的自然数。AI (CI翻译)

Output

输出格式

AI (CI翻译)

If there’s no such set of words, in the single line output NO. Otherwise, in the first line output YES, and in the next $*N*$ lines output the words themselves in the order their lengths were given in the input file. If the answer is not unique, output any.

如果不存在这样的单词集合,在一行中输出 NO。否则,第一行输出 YES,接下来的 $*N*$ 行按照输入中给出的长度顺序输出这些单词。如果答案不唯一,输出任意一种。AI (CI翻译)

样例

Input #1
3
1 2 3
Output #1
YES
0
10
110
InputCopy OutputCopy
Input #2
3
1 1 1
Output #2
NO
InputCopy OutputCopy
题目信息
题号
37C
时间限制
2 s
内存限制
256 MB
标签
数据结构
贪心
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。