-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcf37c.cpp
More file actions
58 lines (51 loc) · 826 Bytes
/
cf37c.cpp
File metadata and controls
58 lines (51 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <cstdio>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
const int MAX_N = 1007;
typedef pair<int,int> pii;
int n;
int depth;
string path;
string ans[MAX_N];
void dfs(deque<pii>& v) {
if (v.empty()) {
return;
} else if (v[0].first == depth) {
ans[v[0].second] = path;
v.pop_front();
return;
} else {
++depth;
path += '0';
dfs(v);
*path.rbegin() = '1';
dfs(v);
path.erase(path.end() - 1);
--depth;
}
}
int main() {
deque<pii> v;
scanf("%d", &n);
v.resize(n);
for (int i = 0; i < n; ++i) {
scanf("%d", &v[i].first);
v[i].second = i;
}
sort(v.begin(), v.end());
depth = 0;
path = "";
dfs(v);
if (v.empty()) {
puts("YES");
for (int i = 0; i < n; ++i) {
puts(ans[i].c_str());
}
} else {
puts("NO");
}
return 0;
}