-
Notifications
You must be signed in to change notification settings - Fork 0
/
D. Dividing Island.cpp
99 lines (96 loc) · 2.18 KB
/
D. Dividing Island.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#pragma GCC optimize("O2")
#include <fstream>
#include <string>
#include <iostream>
#include <bitset>
#include <math.h>
#include <string>
#include <algorithm>
#include <assert.h>
#include<bits/stdc++.h>
#include <vector>
#include <queue>
#include<stdio.h>
#include<ctype.h>
#define ll long long
using namespace std;
ll a, b, c, d, n;
int main(){
cin >> a >> b >> c >> d >> n;
char arr[max(b, d)][a + c];
for (int x = 0; x < max(b,d); x++){
for (int y = 0; y < a + c; y++){
arr[x][y] = '0';
}
}
if (d > b){
for (int x = b; x < d; x++){
for (int y = 0; y < a; y++){
arr[x][y] = '.';
}
}
}
else{
for (int x = d; x < b; x++){
for (int y = a; y < a + c; y++){
arr[x][y] = '.';
}
}
}
char cur = 'a';
vector<int> st;
int p = 0;
int temp;
bool forw = true;
for (int x = 0; x < n; x++){
cin >> temp;
st.push_back(temp);
}
if (d > b){
if (b % 2 == 0){
forw = false;
}
}
else{
if (d % 2 == 1){
forw = false;
}
}
for (int x = 0; x < max(b,d); x++){
if (forw){
for (int y = 0; y < a + c; y++){
if (arr[x][y] == '.'){
continue;
}
arr[x][y] = cur;
st[p]--;
if (st[p] == 0){
p++;
cur++;
}
}
forw = false;
}
else{
for (int y = a + c - 1; y >= 0; y--){
if (arr[x][y] == '.'){
continue;
}
arr[x][y] = cur;
st[p]--;
if (st[p] == 0){
p++;
cur++;
}
}
forw = true;
}
}
cout << "YES\n";
for (int x = 0; x < max(b,d); x++){
for (int y = 0; y < a + c; y++){
cout << arr[x][y];
}
cout << "\n";
}
}