-
Notifications
You must be signed in to change notification settings - Fork 3
/
C.cpp
83 lines (82 loc) · 2.18 KB
/
C.cpp
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
#include <bits/stdc++.h>
#define CNO cout << "NO\n"
#define CYES cout << "YES\n"
#define endl '\n'
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128 i128;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int n, m, a, b, c, arr[200010];
ll ans = 0;
string str = "IMPOSSIBLE";
char ch[110][110];
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T--) {
cin >> n >> m >> a >> b >> c;
if ((n * m) % 2) {
cout << str << endl;
continue;
}
if (n % 2) {
a -= m / 2;
if (a < 0) {
cout << str << endl;
continue;
}
for (int i = 1; i <= m; i += 2) {
ch[n][i] = 'y' + (i / 2) % 2;
ch[n][i + 1] = 'y' + (i / 2) % 2;
}
} else if (m % 2) {
b -= n / 2;
if (b < 0) {
cout << str << endl;
continue;
}
for (int i = 1; i <= n; i += 2) {
ch[i][m] = 'y' + (i / 2) % 2;
ch[i + 1][m] = 'y' + (i / 2) % 2;
}
}
for (int i = 1; i < n; i += 2) {
for (int j = 1; j < m; j += 2) {
if (c > 0) {
ch[i][j] = 'a' + (i / 2 + j / 2) % 2;
ch[i][j + 1] = 'a' + (i / 2 + j / 2) % 2;
ch[i + 1][j] = 'a' + (i / 2 + j / 2) % 2;
ch[i + 1][j + 1] = 'a' + (i / 2 + j / 2) % 2;
c -= 1;
} else if (a > 1) {
ch[i][j] = 'c' + (i / 2 + j / 2) % 2;
ch[i][j + 1] = 'c' + (i / 2 + j / 2) % 2;
ch[i + 1][j] = 'e' + (i / 2 + j / 2) % 2;
ch[i + 1][j + 1] = 'e' + (i / 2 + j / 2) % 2;
a -= 2;
} else if (b > 1) {
ch[i][j] = 'h' + (i / 2 + j / 2) % 2;
ch[i][j + 1] = 'j' + (i / 2 + j / 2) % 2;
ch[i + 1][j] = 'h' + (i / 2 + j / 2) % 2;
ch[i + 1][j + 1] = 'j' + (i / 2 + j / 2) % 2;
b -= 2;
} else {
cout << str << endl;
return 0;
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cout << ch[i][j];
}
cout << endl;
}
}
return 0;
}