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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
| #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main() {
vector<pair< pair<int,int>,int > > v(3);
int len = 0;
rep(i,3) {
cin >> v[i].first.first >> v[i].first.second;
v[i].second = i;
if(v[i].first.first < v[i].first.second) {
swap(v[i].first.first, v[i].first.second);
}
len = max(len , v[i].first.first);
}
sort(v.begin(), v.end(),greater<pair<P,int> >());
int a = v[0].first.first, b = v[0].first.second;
int c = v[1].first.first, d = v[1].first.second;
int e = v[2].first.first, f = v[2].first.second;
char A = char('A' + v[0].second);
char B = char('A' + v[1].second);
char C = char('A' + v[2].second);
if(a == len && c == len && e == len) {
if(b + d + f == len) {
cout << len << endl;
rep(i,b) {
rep(j,a) cout << A;
cout << endl;
}
rep(i,d) {
rep(j,c) cout << B;
cout << endl;
}
rep(i,f) {
rep(j,e) cout << C;
cout << endl;
}
} else {
cout << -1 << endl;
}
} else {
if(b + c == len && b + e == len && d + f == len) {
cout << len << endl;
rep(i,b) {
rep(j,a) cout << A;
cout << endl;
}
rep(i,c) {
rep(j,d) cout << B;
rep(j,f) cout << C;
cout << endl;
}
}
else if(b + d == len && b + e == len && c + f == len) {
cout << len << endl;
rep(i,b) {
rep(j,a) cout << A;
cout << endl;
}
rep(i,d) {
rep(j,c) cout << B;
rep(j,f) cout << C;
cout << endl;
}
} else if(b + c == len && b + f == len && d + e == len) {
cout << len << endl;
rep(i,b) {
rep(j,a) cout << A;
cout << endl;
}
rep(i,c) {
rep(j,d) cout << B;
rep(j,e) cout << C;
cout << endl;
}
} else if(b + d == len && b + f == len && c + e == len) {
cout << len << endl;
rep(i,b) {
rep(j,a) cout << A;
cout << endl;
}
rep(i,d) {
rep(j,c) cout << B;
rep(j,e) cout << C;
cout << endl;
}
} else {
cout << -1 << endl;
}
}
return 0;
}
|